@adam-milo/ui 1.0.24 → 1.0.26

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 (158) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +3 -1
  3. package/dist/index10.cjs +1 -1
  4. package/dist/index10.js +1 -1
  5. package/dist/index11.cjs +1 -1
  6. package/dist/index11.js +1 -1
  7. package/dist/index12.cjs +1 -1
  8. package/dist/index12.js +1 -1
  9. package/dist/index13.cjs +1 -1
  10. package/dist/index13.js +1 -1
  11. package/dist/index14.cjs +1 -1
  12. package/dist/index14.js +1 -1
  13. package/dist/index15.cjs +1 -1
  14. package/dist/index15.js +2 -2
  15. package/dist/index16.cjs +1 -1
  16. package/dist/index16.js +1 -1
  17. package/dist/index17.cjs +1 -1
  18. package/dist/index17.js +1 -1
  19. package/dist/index18.cjs +1 -1
  20. package/dist/index18.js +36 -12
  21. package/dist/index19.cjs +1 -0
  22. package/dist/index19.js +14 -0
  23. package/dist/index2.cjs +1 -1
  24. package/dist/index2.js +1 -1
  25. package/dist/index21.cjs +1 -1
  26. package/dist/index21.js +20 -299
  27. package/dist/index22.cjs +1 -1
  28. package/dist/index22.js +298 -13
  29. package/dist/index23.cjs +1 -0
  30. package/dist/index23.js +16 -0
  31. package/dist/{index25.cjs → index26.cjs} +1 -1
  32. package/dist/{index25.js → index26.js} +21 -21
  33. package/dist/index3.cjs +1 -1
  34. package/dist/index3.js +2 -2
  35. package/dist/index38.cjs +1 -1
  36. package/dist/index38.js +18 -3
  37. package/dist/index4.cjs +1 -1
  38. package/dist/index4.js +1 -1
  39. package/dist/index40.cjs +1 -1
  40. package/dist/index40.js +3 -67
  41. package/dist/index41.cjs +1 -1
  42. package/dist/index41.js +6 -34
  43. package/dist/index42.cjs +1 -1
  44. package/dist/index42.js +64 -58
  45. package/dist/index43.cjs +1 -1
  46. package/dist/index43.js +35 -6
  47. package/dist/index44.cjs +1 -1
  48. package/dist/index44.js +53 -201
  49. package/dist/index45.cjs +1 -1
  50. package/dist/index45.js +6 -25
  51. package/dist/index46.cjs +1 -1
  52. package/dist/index46.js +190 -186
  53. package/dist/index47.cjs +1 -1
  54. package/dist/index47.js +24 -9
  55. package/dist/index48.cjs +1 -1
  56. package/dist/index48.js +193 -278
  57. package/dist/index49.cjs +1 -1
  58. package/dist/index49.js +11 -15
  59. package/dist/index5.cjs +1 -1
  60. package/dist/index5.js +1 -1
  61. package/dist/index50.cjs +1 -1
  62. package/dist/index50.js +287 -37
  63. package/dist/index51.cjs +1 -1
  64. package/dist/index51.js +14 -85
  65. package/dist/index52.cjs +1 -1
  66. package/dist/index52.js +38 -9
  67. package/dist/index53.cjs +1 -1
  68. package/dist/index53.js +80 -62
  69. package/dist/index54.cjs +1 -1
  70. package/dist/index54.js +11 -3
  71. package/dist/index55.cjs +1 -1
  72. package/dist/index55.js +66 -9
  73. package/dist/index56.cjs +1 -1
  74. package/dist/index56.js +3 -31
  75. package/dist/index57.cjs +1 -1
  76. package/dist/index57.js +12 -120
  77. package/dist/index58.cjs +1 -1
  78. package/dist/index58.js +30 -7
  79. package/dist/index59.cjs +1 -1
  80. package/dist/index59.js +118 -13
  81. package/dist/index6.cjs +1 -1
  82. package/dist/index6.js +2 -2
  83. package/dist/index60.cjs +1 -1
  84. package/dist/index60.js +7 -293
  85. package/dist/index61.cjs +1 -1
  86. package/dist/index61.js +14 -22
  87. package/dist/index62.cjs +1 -1
  88. package/dist/index62.js +291 -33
  89. package/dist/index63.cjs +1 -1
  90. package/dist/index63.js +22 -622
  91. package/dist/index64.cjs +1 -1
  92. package/dist/index64.js +35 -35
  93. package/dist/index65.cjs +1 -1
  94. package/dist/index65.js +620 -33
  95. package/dist/index66.cjs +1 -1
  96. package/dist/index66.js +37 -5
  97. package/dist/index67.cjs +1 -1
  98. package/dist/index67.js +36 -8
  99. package/dist/index68.cjs +1 -1
  100. package/dist/index68.js +5 -3
  101. package/dist/index69.cjs +1 -1
  102. package/dist/index69.js +8 -33
  103. package/dist/index7.cjs +1 -1
  104. package/dist/index7.js +1 -1
  105. package/dist/index70.cjs +1 -1
  106. package/dist/index70.js +3 -178
  107. package/dist/index71.cjs +1 -1
  108. package/dist/index71.js +31 -17
  109. package/dist/index72.cjs +1 -1
  110. package/dist/index72.js +165 -706
  111. package/dist/index73.cjs +1 -1
  112. package/dist/index73.js +16 -149
  113. package/dist/index74.cjs +1 -1
  114. package/dist/index74.js +697 -149
  115. package/dist/index75.cjs +1 -1
  116. package/dist/index75.js +146 -80
  117. package/dist/index76.cjs +1 -1
  118. package/dist/index76.js +170 -44
  119. package/dist/index77.cjs +1 -1
  120. package/dist/index77.js +44 -10
  121. package/dist/index78.cjs +1 -1
  122. package/dist/index78.js +11 -17
  123. package/dist/index79.cjs +1 -1
  124. package/dist/index79.js +14 -97
  125. package/dist/index8.cjs +1 -1
  126. package/dist/index8.js +1 -1
  127. package/dist/index80.cjs +1 -1
  128. package/dist/index80.js +99 -8
  129. package/dist/index81.cjs +1 -1
  130. package/dist/index81.js +82 -23
  131. package/dist/index82.cjs +1 -1
  132. package/dist/index82.js +9 -14
  133. package/dist/index83.cjs +1 -1
  134. package/dist/index83.js +25 -44
  135. package/dist/index84.cjs +1 -1
  136. package/dist/index84.js +33 -5
  137. package/dist/index85.cjs +1 -1
  138. package/dist/index85.js +12 -33
  139. package/dist/index86.cjs +1 -0
  140. package/dist/index86.js +48 -0
  141. package/dist/index87.cjs +1 -0
  142. package/dist/index87.js +9 -0
  143. package/dist/index9.cjs +1 -1
  144. package/dist/index9.js +2 -2
  145. package/dist/src/components/layout/container/Container.component.d.ts +26 -0
  146. package/dist/src/components/layout/container/Container.component.d.ts.map +1 -0
  147. package/dist/src/index.d.ts +2 -0
  148. package/dist/src/index.d.ts.map +1 -1
  149. package/dist/style.css +1 -1
  150. package/package.json +2 -1
  151. package/dist/index20.cjs +0 -1
  152. package/dist/index20.js +0 -22
  153. package/dist/index36.cjs +0 -1
  154. package/dist/index36.js +0 -21
  155. package/dist/index39.cjs +0 -1
  156. package/dist/index39.js +0 -11
  157. /package/dist/{index33.cjs → index34.cjs} +0 -0
  158. /package/dist/{index33.js → index34.js} +0 -0
package/dist/index72.js CHANGED
@@ -1,721 +1,180 @@
1
- import { evaluate, getSideAxis, getSide, clamp, getOppositePlacement, getExpandedPlacements, getOppositeAxisPlacements, getAlignmentSides, getAlignment, min, max, getPaddingObject, rectToClientRect, getOppositeAxis, getAlignmentAxis, sides, getAxisLength } from "./index73.js";
2
- function computeCoordsFromPlacement(_ref, placement, rtl) {
3
- let {
4
- reference,
5
- floating
6
- } = _ref;
7
- const sideAxis = getSideAxis(placement);
8
- const alignmentAxis = getAlignmentAxis(placement);
9
- const alignLength = getAxisLength(alignmentAxis);
10
- const side = getSide(placement);
11
- const isVertical = sideAxis === "y";
12
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
13
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
14
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
15
- let coords;
16
- switch (side) {
17
- case "top":
18
- coords = {
19
- x: commonX,
20
- y: reference.y - floating.height
21
- };
22
- break;
23
- case "bottom":
24
- coords = {
25
- x: commonX,
26
- y: reference.y + reference.height
27
- };
28
- break;
29
- case "right":
30
- coords = {
31
- x: reference.x + reference.width,
32
- y: commonY
33
- };
34
- break;
35
- case "left":
36
- coords = {
37
- x: reference.x - floating.width,
38
- y: commonY
39
- };
40
- break;
41
- default:
42
- coords = {
43
- x: reference.x,
44
- y: reference.y
1
+ import { __spreadArray } from "./index66.js";
2
+ import * as React from "react";
3
+ import { RemoveScrollBar } from "./index77.js";
4
+ import { styleSingleton } from "./index78.js";
5
+ import { nonPassive } from "./index79.js";
6
+ import { locationCouldBeScrolled, handleScroll } from "./index80.js";
7
+ var getTouchXY = function(event) {
8
+ return "changedTouches" in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
9
+ };
10
+ var getDeltaXY = function(event) {
11
+ return [event.deltaX, event.deltaY];
12
+ };
13
+ var extractRef = function(ref) {
14
+ return ref && "current" in ref ? ref.current : ref;
15
+ };
16
+ var deltaCompare = function(x, y) {
17
+ return x[0] === y[0] && x[1] === y[1];
18
+ };
19
+ var generateStyle = function(id) {
20
+ return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n");
21
+ };
22
+ var idCounter = 0;
23
+ var lockStack = [];
24
+ function RemoveScrollSideCar(props) {
25
+ var shouldPreventQueue = React.useRef([]);
26
+ var touchStartRef = React.useRef([0, 0]);
27
+ var activeAxis = React.useRef();
28
+ var id = React.useState(idCounter++)[0];
29
+ var Style = React.useState(styleSingleton)[0];
30
+ var lastProps = React.useRef(props);
31
+ React.useEffect(function() {
32
+ lastProps.current = props;
33
+ }, [props]);
34
+ React.useEffect(function() {
35
+ if (props.inert) {
36
+ document.body.classList.add("block-interactivity-".concat(id));
37
+ var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
38
+ allow_1.forEach(function(el) {
39
+ return el.classList.add("allow-interactivity-".concat(id));
40
+ });
41
+ return function() {
42
+ document.body.classList.remove("block-interactivity-".concat(id));
43
+ allow_1.forEach(function(el) {
44
+ return el.classList.remove("allow-interactivity-".concat(id));
45
+ });
45
46
  };
46
- }
47
- switch (getAlignment(placement)) {
48
- case "start":
49
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
50
- break;
51
- case "end":
52
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
53
- break;
54
- }
55
- return coords;
56
- }
57
- const computePosition = async (reference, floating, config) => {
58
- const {
59
- placement = "bottom",
60
- strategy = "absolute",
61
- middleware = [],
62
- platform
63
- } = config;
64
- const validMiddleware = middleware.filter(Boolean);
65
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
66
- let rects = await platform.getElementRects({
67
- reference,
68
- floating,
69
- strategy
70
- });
71
- let {
72
- x,
73
- y
74
- } = computeCoordsFromPlacement(rects, placement, rtl);
75
- let statefulPlacement = placement;
76
- let middlewareData = {};
77
- let resetCount = 0;
78
- for (let i = 0; i < validMiddleware.length; i++) {
79
- const {
80
- name,
81
- fn
82
- } = validMiddleware[i];
83
- const {
84
- x: nextX,
85
- y: nextY,
86
- data,
87
- reset
88
- } = await fn({
89
- x,
90
- y,
91
- initialPlacement: placement,
92
- placement: statefulPlacement,
93
- strategy,
94
- middlewareData,
95
- rects,
96
- platform,
97
- elements: {
98
- reference,
99
- floating
100
- }
101
- });
102
- x = nextX != null ? nextX : x;
103
- y = nextY != null ? nextY : y;
104
- middlewareData = {
105
- ...middlewareData,
106
- [name]: {
107
- ...middlewareData[name],
108
- ...data
109
- }
110
- };
111
- if (reset && resetCount <= 50) {
112
- resetCount++;
113
- if (typeof reset === "object") {
114
- if (reset.placement) {
115
- statefulPlacement = reset.placement;
116
- }
117
- if (reset.rects) {
118
- rects = reset.rects === true ? await platform.getElementRects({
119
- reference,
120
- floating,
121
- strategy
122
- }) : reset.rects;
123
- }
124
- ({
125
- x,
126
- y
127
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
128
- }
129
- i = -1;
130
47
  }
131
- }
132
- return {
133
- x,
134
- y,
135
- placement: statefulPlacement,
136
- strategy,
137
- middlewareData
138
- };
139
- };
140
- async function detectOverflow(state, options) {
141
- var _await$platform$isEle;
142
- if (options === void 0) {
143
- options = {};
144
- }
145
- const {
146
- x,
147
- y,
148
- platform,
149
- rects,
150
- elements,
151
- strategy
152
- } = state;
153
- const {
154
- boundary = "clippingAncestors",
155
- rootBoundary = "viewport",
156
- elementContext = "floating",
157
- altBoundary = false,
158
- padding = 0
159
- } = evaluate(options, state);
160
- const paddingObject = getPaddingObject(padding);
161
- const altContext = elementContext === "floating" ? "reference" : "floating";
162
- const element = elements[altBoundary ? altContext : elementContext];
163
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
164
- element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating)),
165
- boundary,
166
- rootBoundary,
167
- strategy
168
- }));
169
- const rect = elementContext === "floating" ? {
170
- x,
171
- y,
172
- width: rects.floating.width,
173
- height: rects.floating.height
174
- } : rects.reference;
175
- const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
176
- const offsetScale = await (platform.isElement == null ? void 0 : platform.isElement(offsetParent)) ? await (platform.getScale == null ? void 0 : platform.getScale(offsetParent)) || {
177
- x: 1,
178
- y: 1
179
- } : {
180
- x: 1,
181
- y: 1
182
- };
183
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
184
- elements,
185
- rect,
186
- offsetParent,
187
- strategy
188
- }) : rect);
189
- return {
190
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
191
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
192
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
193
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
194
- };
195
- }
196
- const arrow = (options) => ({
197
- name: "arrow",
198
- options,
199
- async fn(state) {
200
- const {
201
- x,
202
- y,
203
- placement,
204
- rects,
205
- platform,
206
- elements,
207
- middlewareData
208
- } = state;
209
- const {
210
- element,
211
- padding = 0
212
- } = evaluate(options, state) || {};
213
- if (element == null) {
214
- return {};
48
+ return;
49
+ }, [props.inert, props.lockRef.current, props.shards]);
50
+ var shouldCancelEvent = React.useCallback(function(event, parent) {
51
+ if ("touches" in event && event.touches.length === 2 || event.type === "wheel" && event.ctrlKey) {
52
+ return !lastProps.current.allowPinchZoom;
215
53
  }
216
- const paddingObject = getPaddingObject(padding);
217
- const coords = {
218
- x,
219
- y
220
- };
221
- const axis = getAlignmentAxis(placement);
222
- const length = getAxisLength(axis);
223
- const arrowDimensions = await platform.getDimensions(element);
224
- const isYAxis = axis === "y";
225
- const minProp = isYAxis ? "top" : "left";
226
- const maxProp = isYAxis ? "bottom" : "right";
227
- const clientProp = isYAxis ? "clientHeight" : "clientWidth";
228
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
229
- const startDiff = coords[axis] - rects.reference[axis];
230
- const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
231
- let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
232
- if (!clientSize || !await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent))) {
233
- clientSize = elements.floating[clientProp] || rects.floating[length];
54
+ var touch = getTouchXY(event);
55
+ var touchStart = touchStartRef.current;
56
+ var deltaX = "deltaX" in event ? event.deltaX : touchStart[0] - touch[0];
57
+ var deltaY = "deltaY" in event ? event.deltaY : touchStart[1] - touch[1];
58
+ var currentAxis;
59
+ var target = event.target;
60
+ var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? "h" : "v";
61
+ if ("touches" in event && moveDirection === "h" && target.type === "range") {
62
+ return false;
234
63
  }
235
- const centerToReference = endDiff / 2 - startDiff / 2;
236
- const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
237
- const minPadding = min(paddingObject[minProp], largestPossiblePadding);
238
- const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
239
- const min$1 = minPadding;
240
- const max2 = clientSize - arrowDimensions[length] - maxPadding;
241
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
242
- const offset2 = clamp(min$1, center, max2);
243
- const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
244
- const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
245
- return {
246
- [axis]: coords[axis] + alignmentOffset,
247
- data: {
248
- [axis]: offset2,
249
- centerOffset: center - offset2 - alignmentOffset,
250
- ...shouldAddOffset && {
251
- alignmentOffset
252
- }
253
- },
254
- reset: shouldAddOffset
255
- };
256
- }
257
- });
258
- const flip = function(options) {
259
- if (options === void 0) {
260
- options = {};
261
- }
262
- return {
263
- name: "flip",
264
- options,
265
- async fn(state) {
266
- var _middlewareData$arrow, _middlewareData$flip;
267
- const {
268
- placement,
269
- middlewareData,
270
- rects,
271
- initialPlacement,
272
- platform,
273
- elements
274
- } = state;
275
- const {
276
- mainAxis: checkMainAxis = true,
277
- crossAxis: checkCrossAxis = true,
278
- fallbackPlacements: specifiedFallbackPlacements,
279
- fallbackStrategy = "bestFit",
280
- fallbackAxisSideDirection = "none",
281
- flipAlignment = true,
282
- ...detectOverflowOptions
283
- } = evaluate(options, state);
284
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
285
- return {};
286
- }
287
- const side = getSide(placement);
288
- const initialSideAxis = getSideAxis(initialPlacement);
289
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
290
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
291
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
292
- const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
293
- if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
294
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
295
- }
296
- const placements = [initialPlacement, ...fallbackPlacements];
297
- const overflow = await detectOverflow(state, detectOverflowOptions);
298
- const overflows = [];
299
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
300
- if (checkMainAxis) {
301
- overflows.push(overflow[side]);
302
- }
303
- if (checkCrossAxis) {
304
- const sides2 = getAlignmentSides(placement, rects, rtl);
305
- overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
306
- }
307
- overflowsData = [...overflowsData, {
308
- placement,
309
- overflows
310
- }];
311
- if (!overflows.every((side2) => side2 <= 0)) {
312
- var _middlewareData$flip2, _overflowsData$filter;
313
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
314
- const nextPlacement = placements[nextIndex];
315
- if (nextPlacement) {
316
- const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
317
- if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
318
- // overflows the main axis.
319
- overflowsData.every((d) => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
320
- return {
321
- data: {
322
- index: nextIndex,
323
- overflows: overflowsData
324
- },
325
- reset: {
326
- placement: nextPlacement
327
- }
328
- };
329
- }
330
- }
331
- let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
332
- if (!resetPlacement) {
333
- switch (fallbackStrategy) {
334
- case "bestFit": {
335
- var _overflowsData$filter2;
336
- const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
337
- if (hasFallbackAxisSideDirection) {
338
- const currentSideAxis = getSideAxis(d.placement);
339
- return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
340
- // reading directions favoring greater width.
341
- currentSideAxis === "y";
342
- }
343
- return true;
344
- }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
345
- if (placement2) {
346
- resetPlacement = placement2;
347
- }
348
- break;
349
- }
350
- case "initialPlacement":
351
- resetPlacement = initialPlacement;
352
- break;
353
- }
354
- }
355
- if (placement !== resetPlacement) {
356
- return {
357
- reset: {
358
- placement: resetPlacement
359
- }
360
- };
361
- }
362
- }
363
- return {};
64
+ var selection = window.getSelection();
65
+ var anchorNode = selection && selection.anchorNode;
66
+ var isTouchingSelection = anchorNode ? anchorNode === target || anchorNode.contains(target) : false;
67
+ if (isTouchingSelection) {
68
+ return false;
364
69
  }
365
- };
366
- };
367
- function getSideOffsets(overflow, rect) {
368
- return {
369
- top: overflow.top - rect.height,
370
- right: overflow.right - rect.width,
371
- bottom: overflow.bottom - rect.height,
372
- left: overflow.left - rect.width
373
- };
374
- }
375
- function isAnySideFullyClipped(overflow) {
376
- return sides.some((side) => overflow[side] >= 0);
377
- }
378
- const hide = function(options) {
379
- if (options === void 0) {
380
- options = {};
381
- }
382
- return {
383
- name: "hide",
384
- options,
385
- async fn(state) {
386
- const {
387
- rects
388
- } = state;
389
- const {
390
- strategy = "referenceHidden",
391
- ...detectOverflowOptions
392
- } = evaluate(options, state);
393
- switch (strategy) {
394
- case "referenceHidden": {
395
- const overflow = await detectOverflow(state, {
396
- ...detectOverflowOptions,
397
- elementContext: "reference"
398
- });
399
- const offsets = getSideOffsets(overflow, rects.reference);
400
- return {
401
- data: {
402
- referenceHiddenOffsets: offsets,
403
- referenceHidden: isAnySideFullyClipped(offsets)
404
- }
405
- };
406
- }
407
- case "escaped": {
408
- const overflow = await detectOverflow(state, {
409
- ...detectOverflowOptions,
410
- altBoundary: true
411
- });
412
- const offsets = getSideOffsets(overflow, rects.floating);
413
- return {
414
- data: {
415
- escapedOffsets: offsets,
416
- escaped: isAnySideFullyClipped(offsets)
417
- }
418
- };
419
- }
420
- default: {
421
- return {};
422
- }
423
- }
70
+ var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
71
+ if (!canBeScrolledInMainDirection) {
72
+ return true;
424
73
  }
425
- };
426
- };
427
- const originSides = /* @__PURE__ */ new Set(["left", "top"]);
428
- async function convertValueToCoords(state, options) {
429
- const {
430
- placement,
431
- platform,
432
- elements
433
- } = state;
434
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
435
- const side = getSide(placement);
436
- const alignment = getAlignment(placement);
437
- const isVertical = getSideAxis(placement) === "y";
438
- const mainAxisMulti = originSides.has(side) ? -1 : 1;
439
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
440
- const rawValue = evaluate(options, state);
441
- let {
442
- mainAxis,
443
- crossAxis,
444
- alignmentAxis
445
- } = typeof rawValue === "number" ? {
446
- mainAxis: rawValue,
447
- crossAxis: 0,
448
- alignmentAxis: null
449
- } : {
450
- mainAxis: rawValue.mainAxis || 0,
451
- crossAxis: rawValue.crossAxis || 0,
452
- alignmentAxis: rawValue.alignmentAxis
453
- };
454
- if (alignment && typeof alignmentAxis === "number") {
455
- crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
456
- }
457
- return isVertical ? {
458
- x: crossAxis * crossAxisMulti,
459
- y: mainAxis * mainAxisMulti
460
- } : {
461
- x: mainAxis * mainAxisMulti,
462
- y: crossAxis * crossAxisMulti
463
- };
464
- }
465
- const offset = function(options) {
466
- if (options === void 0) {
467
- options = 0;
468
- }
469
- return {
470
- name: "offset",
471
- options,
472
- async fn(state) {
473
- var _middlewareData$offse, _middlewareData$arrow;
474
- const {
475
- x,
476
- y,
477
- placement,
478
- middlewareData
479
- } = state;
480
- const diffCoords = await convertValueToCoords(state, options);
481
- if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
482
- return {};
483
- }
484
- return {
485
- x: x + diffCoords.x,
486
- y: y + diffCoords.y,
487
- data: {
488
- ...diffCoords,
489
- placement
490
- }
491
- };
74
+ if (canBeScrolledInMainDirection) {
75
+ currentAxis = moveDirection;
76
+ } else {
77
+ currentAxis = moveDirection === "v" ? "h" : "v";
78
+ canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
492
79
  }
493
- };
494
- };
495
- const shift = function(options) {
496
- if (options === void 0) {
497
- options = {};
498
- }
499
- return {
500
- name: "shift",
501
- options,
502
- async fn(state) {
503
- const {
504
- x,
505
- y,
506
- placement
507
- } = state;
508
- const {
509
- mainAxis: checkMainAxis = true,
510
- crossAxis: checkCrossAxis = false,
511
- limiter = {
512
- fn: (_ref) => {
513
- let {
514
- x: x2,
515
- y: y2
516
- } = _ref;
517
- return {
518
- x: x2,
519
- y: y2
520
- };
521
- }
522
- },
523
- ...detectOverflowOptions
524
- } = evaluate(options, state);
525
- const coords = {
526
- x,
527
- y
528
- };
529
- const overflow = await detectOverflow(state, detectOverflowOptions);
530
- const crossAxis = getSideAxis(getSide(placement));
531
- const mainAxis = getOppositeAxis(crossAxis);
532
- let mainAxisCoord = coords[mainAxis];
533
- let crossAxisCoord = coords[crossAxis];
534
- if (checkMainAxis) {
535
- const minSide = mainAxis === "y" ? "top" : "left";
536
- const maxSide = mainAxis === "y" ? "bottom" : "right";
537
- const min2 = mainAxisCoord + overflow[minSide];
538
- const max2 = mainAxisCoord - overflow[maxSide];
539
- mainAxisCoord = clamp(min2, mainAxisCoord, max2);
540
- }
541
- if (checkCrossAxis) {
542
- const minSide = crossAxis === "y" ? "top" : "left";
543
- const maxSide = crossAxis === "y" ? "bottom" : "right";
544
- const min2 = crossAxisCoord + overflow[minSide];
545
- const max2 = crossAxisCoord - overflow[maxSide];
546
- crossAxisCoord = clamp(min2, crossAxisCoord, max2);
547
- }
548
- const limitedCoords = limiter.fn({
549
- ...state,
550
- [mainAxis]: mainAxisCoord,
551
- [crossAxis]: crossAxisCoord
552
- });
553
- return {
554
- ...limitedCoords,
555
- data: {
556
- x: limitedCoords.x - x,
557
- y: limitedCoords.y - y,
558
- enabled: {
559
- [mainAxis]: checkMainAxis,
560
- [crossAxis]: checkCrossAxis
561
- }
562
- }
563
- };
80
+ if (!canBeScrolledInMainDirection) {
81
+ return false;
564
82
  }
565
- };
566
- };
567
- const limitShift = function(options) {
568
- if (options === void 0) {
569
- options = {};
570
- }
571
- return {
572
- options,
573
- fn(state) {
574
- const {
575
- x,
576
- y,
577
- placement,
578
- rects,
579
- middlewareData
580
- } = state;
581
- const {
582
- offset: offset2 = 0,
583
- mainAxis: checkMainAxis = true,
584
- crossAxis: checkCrossAxis = true
585
- } = evaluate(options, state);
586
- const coords = {
587
- x,
588
- y
589
- };
590
- const crossAxis = getSideAxis(placement);
591
- const mainAxis = getOppositeAxis(crossAxis);
592
- let mainAxisCoord = coords[mainAxis];
593
- let crossAxisCoord = coords[crossAxis];
594
- const rawOffset = evaluate(offset2, state);
595
- const computedOffset = typeof rawOffset === "number" ? {
596
- mainAxis: rawOffset,
597
- crossAxis: 0
598
- } : {
599
- mainAxis: 0,
600
- crossAxis: 0,
601
- ...rawOffset
602
- };
603
- if (checkMainAxis) {
604
- const len = mainAxis === "y" ? "height" : "width";
605
- const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
606
- const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
607
- if (mainAxisCoord < limitMin) {
608
- mainAxisCoord = limitMin;
609
- } else if (mainAxisCoord > limitMax) {
610
- mainAxisCoord = limitMax;
611
- }
612
- }
613
- if (checkCrossAxis) {
614
- var _middlewareData$offse, _middlewareData$offse2;
615
- const len = mainAxis === "y" ? "width" : "height";
616
- const isOriginSide = originSides.has(getSide(placement));
617
- const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
618
- const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
619
- if (crossAxisCoord < limitMin) {
620
- crossAxisCoord = limitMin;
621
- } else if (crossAxisCoord > limitMax) {
622
- crossAxisCoord = limitMax;
623
- }
624
- }
625
- return {
626
- [mainAxis]: mainAxisCoord,
627
- [crossAxis]: crossAxisCoord
628
- };
83
+ if (!activeAxis.current && "changedTouches" in event && (deltaX || deltaY)) {
84
+ activeAxis.current = currentAxis;
629
85
  }
630
- };
631
- };
632
- const size = function(options) {
633
- if (options === void 0) {
634
- options = {};
635
- }
636
- return {
637
- name: "size",
638
- options,
639
- async fn(state) {
640
- var _state$middlewareData, _state$middlewareData2;
641
- const {
642
- placement,
643
- rects,
644
- platform,
645
- elements
646
- } = state;
647
- const {
648
- apply = () => {
649
- },
650
- ...detectOverflowOptions
651
- } = evaluate(options, state);
652
- const overflow = await detectOverflow(state, detectOverflowOptions);
653
- const side = getSide(placement);
654
- const alignment = getAlignment(placement);
655
- const isYAxis = getSideAxis(placement) === "y";
656
- const {
657
- width,
658
- height
659
- } = rects.floating;
660
- let heightSide;
661
- let widthSide;
662
- if (side === "top" || side === "bottom") {
663
- heightSide = side;
664
- widthSide = alignment === (await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
665
- } else {
666
- widthSide = side;
667
- heightSide = alignment === "end" ? "top" : "bottom";
668
- }
669
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
670
- const maximumClippingWidth = width - overflow.left - overflow.right;
671
- const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
672
- const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
673
- const noShift = !state.middlewareData.shift;
674
- let availableHeight = overflowAvailableHeight;
675
- let availableWidth = overflowAvailableWidth;
676
- if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
677
- availableWidth = maximumClippingWidth;
678
- }
679
- if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
680
- availableHeight = maximumClippingHeight;
681
- }
682
- if (noShift && !alignment) {
683
- const xMin = max(overflow.left, 0);
684
- const xMax = max(overflow.right, 0);
685
- const yMin = max(overflow.top, 0);
686
- const yMax = max(overflow.bottom, 0);
687
- if (isYAxis) {
688
- availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
689
- } else {
690
- availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
86
+ if (!currentAxis) {
87
+ return true;
88
+ }
89
+ var cancelingAxis = activeAxis.current || currentAxis;
90
+ return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY);
91
+ }, []);
92
+ var shouldPrevent = React.useCallback(function(_event) {
93
+ var event = _event;
94
+ if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
95
+ return;
96
+ }
97
+ var delta = "deltaY" in event ? getDeltaXY(event) : getTouchXY(event);
98
+ var sourceEvent = shouldPreventQueue.current.filter(function(e) {
99
+ return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta);
100
+ })[0];
101
+ if (sourceEvent && sourceEvent.should) {
102
+ if (event.cancelable) {
103
+ event.preventDefault();
104
+ }
105
+ return;
106
+ }
107
+ if (!sourceEvent) {
108
+ var shardNodes = (lastProps.current.shards || []).map(extractRef).filter(Boolean).filter(function(node) {
109
+ return node.contains(event.target);
110
+ });
111
+ var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
112
+ if (shouldStop) {
113
+ if (event.cancelable) {
114
+ event.preventDefault();
691
115
  }
692
116
  }
693
- await apply({
694
- ...state,
695
- availableWidth,
696
- availableHeight
117
+ }
118
+ }, []);
119
+ var shouldCancel = React.useCallback(function(name, delta, target, should) {
120
+ var event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) };
121
+ shouldPreventQueue.current.push(event);
122
+ setTimeout(function() {
123
+ shouldPreventQueue.current = shouldPreventQueue.current.filter(function(e) {
124
+ return e !== event;
697
125
  });
698
- const nextDimensions = await platform.getDimensions(elements.floating);
699
- if (width !== nextDimensions.width || height !== nextDimensions.height) {
700
- return {
701
- reset: {
702
- rects: true
703
- }
704
- };
705
- }
706
- return {};
126
+ }, 1);
127
+ }, []);
128
+ var scrollTouchStart = React.useCallback(function(event) {
129
+ touchStartRef.current = getTouchXY(event);
130
+ activeAxis.current = void 0;
131
+ }, []);
132
+ var scrollWheel = React.useCallback(function(event) {
133
+ shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
134
+ }, []);
135
+ var scrollTouchMove = React.useCallback(function(event) {
136
+ shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
137
+ }, []);
138
+ React.useEffect(function() {
139
+ lockStack.push(Style);
140
+ props.setCallbacks({
141
+ onScrollCapture: scrollWheel,
142
+ onWheelCapture: scrollWheel,
143
+ onTouchMoveCapture: scrollTouchMove
144
+ });
145
+ document.addEventListener("wheel", shouldPrevent, nonPassive);
146
+ document.addEventListener("touchmove", shouldPrevent, nonPassive);
147
+ document.addEventListener("touchstart", scrollTouchStart, nonPassive);
148
+ return function() {
149
+ lockStack = lockStack.filter(function(inst) {
150
+ return inst !== Style;
151
+ });
152
+ document.removeEventListener("wheel", shouldPrevent, nonPassive);
153
+ document.removeEventListener("touchmove", shouldPrevent, nonPassive);
154
+ document.removeEventListener("touchstart", scrollTouchStart, nonPassive);
155
+ };
156
+ }, []);
157
+ var removeScrollBar = props.removeScrollBar, inert = props.inert;
158
+ return React.createElement(
159
+ React.Fragment,
160
+ null,
161
+ inert ? React.createElement(Style, { styles: generateStyle(id) }) : null,
162
+ removeScrollBar ? React.createElement(RemoveScrollBar, { noRelative: props.noRelative, gapMode: props.gapMode }) : null
163
+ );
164
+ }
165
+ function getOutermostShadowParent(node) {
166
+ var shadowParent = null;
167
+ while (node !== null) {
168
+ if (node instanceof ShadowRoot) {
169
+ shadowParent = node.host;
170
+ node = node.host;
707
171
  }
708
- };
709
- };
172
+ node = node.parentNode;
173
+ }
174
+ return shadowParent;
175
+ }
710
176
  export {
711
- arrow,
712
- computePosition,
713
- detectOverflow,
714
- flip,
715
- hide,
716
- limitShift,
717
- offset,
718
- rectToClientRect,
719
- shift,
720
- size
177
+ RemoveScrollSideCar,
178
+ getDeltaXY,
179
+ getTouchXY
721
180
  };