@wix/site-ui 1.346.0 → 1.348.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{6706.js → 1093.js} +3 -3
- package/dist/{8724.js → 1219.js} +2 -2
- package/dist/{7373.js → 1288.js} +8 -2
- package/dist/{5299.js → 1381.js} +98 -127
- package/dist/{3056.js → 1607.js} +32 -34
- package/dist/1629.js +2 -0
- package/dist/1669.js +75 -0
- package/dist/1718.js +26 -0
- package/dist/{1477.js → 201.js} +17 -26
- package/dist/2221.js +9 -0
- package/dist/{2445.js → 226.js} +12 -48
- package/dist/2387.js +7 -0
- package/dist/2580.js +6 -0
- package/dist/{1500.js → 2859.js} +10 -34
- package/dist/3014.js +178 -0
- package/dist/{6247.js → 3054.js} +3 -3
- package/dist/{7642.js → 3093.js} +1 -1
- package/dist/3189.js +5 -0
- package/dist/{7564.js → 331.js} +2 -2
- package/dist/3357.js +7 -0
- package/dist/{487.js → 3398.js} +38 -39
- package/dist/3502.js +224 -0
- package/dist/3695.js +50 -0
- package/dist/3829.js +1 -1
- package/dist/{6588.js → 3859.js} +115 -92
- package/dist/{3670.js → 3910.js} +28 -21
- package/dist/392.js +7 -0
- package/dist/{4549.js → 4155.js} +11 -3
- package/dist/4226.js +7 -0
- package/dist/{6329.js → 4229.js} +1 -1
- package/dist/4293.js +3 -0
- package/dist/4346.js +853 -2
- package/dist/{285.js → 4472.js} +3 -3
- package/dist/4605.js +207 -0
- package/dist/{7366.js → 488.js} +60 -7
- package/dist/{8750.js → 497.js} +190 -375
- package/dist/4989.js +35 -0
- package/dist/{6270.js → 510.js} +157 -196
- package/dist/5258.js +26 -0
- package/dist/{5036.js → 5275.js} +0 -3
- package/dist/{8171.js → 5298.js} +90 -102
- package/dist/5473.js +11 -0
- package/dist/{4745.js → 5490.js} +3 -1
- package/dist/{6089.js → 5561.js} +869 -786
- package/dist/{8996.js → 5595.js} +4 -3
- package/dist/5890.js +25 -0
- package/dist/{6046.js → 5969.js} +1 -1
- package/dist/5984.js +38 -0
- package/dist/{8527.js → 6006.js} +3 -3
- package/dist/6040.js +97 -0
- package/dist/{8758.js → 6137.js} +10 -8
- package/dist/{4281.js → 6140.js} +18 -10
- package/dist/{8960.js → 6191.js} +2 -2
- package/dist/6240.js +121 -0
- package/dist/{4490.js → 6373.js} +7 -5
- package/dist/{904.js → 6487.js} +19 -17
- package/dist/{9635.js → 6498.js} +1 -1
- package/dist/6499.js +4 -7
- package/dist/6508.js +7 -0
- package/dist/{8225.js → 6540.js} +1 -0
- package/dist/6551.js +46 -0
- package/dist/{9369.js → 6620.js} +35 -34
- package/dist/{4143.js → 6838.js} +19 -10
- package/dist/6902.js +48 -0
- package/dist/6904.js +51 -0
- package/dist/70.js +24 -0
- package/dist/7024.js +39 -0
- package/dist/{6882.js → 721.js} +737 -362
- package/dist/{951.js → 7270.js} +4 -4
- package/dist/{3485.js → 7323.js} +143 -111
- package/dist/{7541.js → 7488.js} +2 -2
- package/dist/{4863.js → 7542.js} +7 -6
- package/dist/7551.js +28 -0
- package/dist/{7021.js → 7640.js} +1 -1
- package/dist/{353.js → 7692.js} +3 -7
- package/dist/{4707.js → 7930.js} +2 -2
- package/dist/{8052.js → 8.js} +80 -64
- package/dist/{6914.js → 8129.js} +3 -15
- package/dist/{3319.js → 8358.js} +62 -63
- package/dist/{5864.js → 8407.js} +13 -13
- package/dist/8488.js +15 -0
- package/dist/{4768.js → 8495.js} +1 -1
- package/dist/8734.js +171 -0
- package/dist/{1763.js → 9018.js} +205 -331
- package/dist/9053.js +29 -0
- package/dist/9067.js +41 -0
- package/dist/{2861.js → 9120.js} +2 -2
- package/dist/{42.js → 9197.js} +2 -2
- package/dist/{9189.js → 9248.js} +36 -17
- package/dist/{2801.js → 9252.js} +4 -9
- package/dist/9295.js +7 -0
- package/dist/9303.js +8 -0
- package/dist/{167.js → 9374.js} +1 -1
- package/dist/{9352.js → 9540.js} +17 -47
- package/dist/9576.js +51 -0
- package/dist/{8272.js → 9591.js} +36 -46
- package/dist/{6107.js → 9770.js} +2 -2
- package/dist/{5085.js → 9880.js} +6 -3
- package/dist/Accordion/index.d.ts +207 -41
- package/dist/Accordion/index.js +75 -177
- package/dist/AlertDialog/index.d.ts +440 -140
- package/dist/AlertDialog/index.js +3 -13
- package/dist/Autocomplete/index.d.ts +722 -150
- package/dist/Autocomplete/index.js +16 -29
- package/dist/Avatar/index.d.ts +38 -3
- package/dist/Avatar/index.js +82 -28
- package/dist/Breadcrumbs/index.d.ts +63 -91
- package/dist/Breadcrumbs/index.js +1 -1
- package/dist/Button/index.d.ts +11 -0
- package/dist/Button/index.js +2 -2
- package/dist/Checkbox/index.d.ts +206 -36
- package/dist/Checkbox/index.js +293 -8
- package/dist/CheckboxField/index.css +1 -1
- package/dist/CheckboxField/index.d.ts +40 -36
- package/dist/CheckboxGroup/index.d.ts +50 -36
- package/dist/CheckboxGroup/index.js +87 -58
- package/dist/CheckboxGroupField/index.css +1 -1
- package/dist/Collapsible/index.d.ts +128 -36
- package/dist/Collapsible/index.js +21 -25
- package/dist/Combobox/index.d.ts +801 -158
- package/dist/Combobox/index.js +70 -114
- package/dist/ContextMenu/index.d.ts +1162 -195
- package/dist/ContextMenu/index.js +46 -36
- package/dist/Dialog/index.d.ts +425 -133
- package/dist/Dialog/index.js +8 -4
- package/dist/Drawer/index.d.ts +589 -144
- package/dist/Drawer/index.js +482 -562
- package/dist/Field/index.css +1 -1
- package/dist/Field/index.d.ts +341 -42
- package/dist/Field/index.js +123 -273
- package/dist/Fieldset/index.d.ts +11 -0
- package/dist/Fieldset/index.js +10 -17
- package/dist/Form/index.d.ts +43 -39
- package/dist/Form/index.js +58 -50
- package/dist/Input/index.css +1 -1
- package/dist/Input/index.d.ts +94 -42
- package/dist/Input/index.js +1 -1
- package/dist/Menu/index.d.ts +1140 -175
- package/dist/Menu/index.js +51 -67
- package/dist/Menubar/index.d.ts +651 -173
- package/dist/Menubar/index.js +12 -16
- package/dist/Meter/index.js +21 -18
- package/dist/NavigationMenu/index.d.ts +370 -86
- package/dist/NavigationMenu/index.js +144 -178
- package/dist/NumberField/index.css +1 -1
- package/dist/NumberField/index.d.ts +507 -47
- package/dist/NumberField/index.js +434 -718
- package/dist/Popover/index.d.ts +561 -142
- package/dist/Popover/index.js +181 -252
- package/dist/PreviewCard/index.d.ts +507 -143
- package/dist/PreviewCard/index.js +97 -151
- package/dist/Progress/index.d.ts +117 -3
- package/dist/Progress/index.js +37 -36
- package/dist/Radio/index.d.ts +177 -7
- package/dist/Radio/index.js +54 -70
- package/dist/RadioField/index.css +1 -1
- package/dist/RadioField/index.d.ts +23 -7
- package/dist/RadioGroup/index.d.ts +51 -37
- package/dist/RadioGroup/index.js +60 -51
- package/dist/RadioGroupField/index.css +1 -1
- package/dist/RadioGroupField/index.d.ts +40 -37
- package/dist/ScrollArea/index.d.ts +295 -1
- package/dist/ScrollArea/index.js +256 -324
- package/dist/Select/index.d.ts +516 -123
- package/dist/Select/index.js +513 -635
- package/dist/SelectField/index.css +1 -1
- package/dist/SelectField/index.d.ts +109 -134
- package/dist/SelectField/index.js +5 -1
- package/dist/Separator/index.d.ts +12 -0
- package/dist/Separator/index.js +1 -1
- package/dist/Slider/index.d.ts +383 -64
- package/dist/Slider/index.js +298 -374
- package/dist/Switch/index.d.ts +184 -37
- package/dist/Switch/index.js +44 -58
- package/dist/Tabs/index.d.ts +220 -35
- package/dist/Tabs/index.js +199 -193
- package/dist/Toast/index.d.ts +280 -64
- package/dist/Toast/index.js +299 -374
- package/dist/Toggle/index.d.ts +55 -35
- package/dist/Toggle/index.js +19 -13
- package/dist/ToggleGroup/index.d.ts +62 -35
- package/dist/ToggleGroup/index.js +13 -31
- package/dist/Toolbar/index.d.ts +117 -2
- package/dist/Toolbar/index.js +31 -43
- package/dist/Tooltip/index.d.ts +507 -150
- package/dist/Tooltip/index.js +163 -213
- package/dist/index.d.ts +12912 -5382
- package/package.json +3 -3
- package/dist/2205.js +0 -26
- package/dist/2274.js +0 -34
- package/dist/2287.js +0 -17
- package/dist/3020.js +0 -7
- package/dist/3021.js +0 -72
- package/dist/3140.js +0 -4
- package/dist/3248.js +0 -307
- package/dist/4026.js +0 -12
- package/dist/4922.js +0 -15
- package/dist/5659.js +0 -4
- package/dist/5992.js +0 -447
- package/dist/6330.js +0 -30
- package/dist/6535.js +0 -72
- package/dist/6917.js +0 -55
- package/dist/7725.js +0 -10
- package/dist/7871.js +0 -38
- package/dist/8106.js +0 -239
- package/dist/8685.js +0 -102
- package/dist/8935.js +0 -8
- package/dist/8971.js +0 -40
- package/dist/8979.js +0 -10
- package/dist/9048.js +0 -52
- package/dist/9087.js +0 -256
- package/dist/9255.js +0 -136
- /package/dist/{1457.js → 1068.js} +0 -0
- /package/dist/{6003.js → 1234.js} +0 -0
- /package/dist/{4723.js → 1282.js} +0 -0
- /package/dist/{6825.js → 1876.js} +0 -0
- /package/dist/{5778.js → 1885.js} +0 -0
- /package/dist/{2445.js.LICENSE.txt → 226.js.LICENSE.txt} +0 -0
- /package/dist/{1279.js → 3278.js} +0 -0
- /package/dist/{3296.js → 5568.js} +0 -0
- /package/dist/{8685.css → 6240.css} +0 -0
- /package/dist/{9829.js → 6488.js} +0 -0
- /package/dist/{9863.js → 6534.js} +0 -0
- /package/dist/{4495.js → 7718.js} +0 -0
- /package/dist/{3395.js → 8866.js} +0 -0
- /package/dist/{2418.js → 9837.js} +0 -0
package/dist/Drawer/index.js
CHANGED
|
@@ -1,53 +1,44 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { clamp } from "../
|
|
8
|
-
import { useStableCallback } from "../
|
|
9
|
-
import { ownerDocument } from "../
|
|
10
|
-
import { error } from "../
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { useBaseUiId } from "../
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
2
|
+
import { DialogClose_DialogClose, useDialogPortalContext, DialogDescription_DialogDescription, DialogTitle_DialogTitle, useDialogRootContext, DialogTrigger_DialogTrigger, useRenderDialogRoot, DialogHandle, DialogViewport_DialogViewport, DialogPortal_DialogPortal } from "../510.js";
|
|
3
|
+
import { useRefWithInit, EMPTY_OBJECT, mergeProps, useRenderElement, NOOP } from "../9591.js";
|
|
4
|
+
import { CommonPopupDataAttributes_open, CommonPopupDataAttributes_closed, popupTransitionStateMapping } from "../6904.js";
|
|
5
|
+
import { useIsoLayoutEffect, SafeReact } from "../3357.js";
|
|
6
|
+
import { utils_formatErrorMessage } from "../5473.js";
|
|
7
|
+
import { clamp } from "../5568.js";
|
|
8
|
+
import { useStableCallback } from "../7488.js";
|
|
9
|
+
import { ownerDocument } from "../6488.js";
|
|
10
|
+
import { error } from "../4293.js";
|
|
11
|
+
import { endingStyle as TransitionStatusDataAttributes_endingStyle, useOpenChangeComplete } from "../6620.js";
|
|
12
|
+
import { FOCUSABLE_POPUP_PROPS, useTriggerRegistration } from "../4346.js";
|
|
13
|
+
import { COMPOSITE_KEYS } from "../2859.js";
|
|
14
|
+
import { FloatingFocusManager } from "../7323.js";
|
|
15
|
+
import { useBaseUiId } from "../5969.js";
|
|
16
|
+
import { isVirtualClick } from "../8358.js";
|
|
17
|
+
import { getElementTransform } from "../7551.js";
|
|
18
|
+
import { getDisplacement, useSwipeDismiss, getElementAtPoint } from "../9018.js";
|
|
19
|
+
import { createChangeEventDetails } from "../8495.js";
|
|
20
|
+
import { BASE_UI_SWIPE_IGNORE_ATTRIBUTE, BASE_UI_SWIPE_IGNORE_SELECTOR } from "../3398.js";
|
|
21
|
+
import { useAnimationFrame } from "../5595.js";
|
|
19
22
|
import { getWindow, isElement } from "../3829.js";
|
|
20
|
-
import {
|
|
21
|
-
import { addEventListener } from "../
|
|
22
|
-
import {
|
|
23
|
-
import { useControlled } from "../
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import { isAndroid } from "../8971.js";
|
|
27
|
-
import { closeWatcher as reason_parts_closeWatcher } from "../2418.js";
|
|
23
|
+
import { contains, activeElement, getTarget, closest } from "../4155.js";
|
|
24
|
+
import { addEventListener } from "../1282.js";
|
|
25
|
+
import { findScrollableTouchTarget } from "../5258.js";
|
|
26
|
+
import { useControlled } from "../6006.js";
|
|
27
|
+
import { android } from "../2221.js";
|
|
28
|
+
import { closeWatcher as reason_parts_closeWatcher } from "../9837.js";
|
|
28
29
|
import * as __rspack_external_react from "react";
|
|
29
30
|
import * as __rspack_external_react_dom_7136dc57 from "react-dom";
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return DrawerPopupCssVars;
|
|
39
|
-
}({});
|
|
40
|
-
let DrawerBackdropCssVars_DrawerBackdropCssVars = /*#__PURE__*/ function(DrawerBackdropCssVars) {
|
|
41
|
-
DrawerBackdropCssVars["swipeProgress"] = "--drawer-swipe-progress";
|
|
42
|
-
return DrawerBackdropCssVars;
|
|
43
|
-
}({});
|
|
44
|
-
const stateAttributesMapping = {
|
|
45
|
-
...popupStateMapping,
|
|
46
|
-
...transitionStatusMapping
|
|
47
|
-
};
|
|
31
|
+
const nestedDrawers = '--nested-drawers';
|
|
32
|
+
const DrawerPopupCssVars_height = '--drawer-height';
|
|
33
|
+
const DrawerPopupCssVars_frontmostHeight = '--drawer-frontmost-height';
|
|
34
|
+
const swipeMovementX = '--drawer-swipe-movement-x';
|
|
35
|
+
const swipeMovementY = '--drawer-swipe-movement-y';
|
|
36
|
+
const snapPointOffset = '--drawer-snap-point-offset';
|
|
37
|
+
const DrawerPopupCssVars_swipeStrength = '--drawer-swipe-strength';
|
|
38
|
+
const DrawerBackdropCssVars_swipeProgress = '--drawer-swipe-progress';
|
|
48
39
|
const DrawerBackdrop_DrawerBackdrop = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
49
40
|
const { render, className, style, forceRender = false, ...elementProps } = componentProps;
|
|
50
|
-
const
|
|
41
|
+
const store = useDialogRootContext();
|
|
51
42
|
const open = store.useState('open');
|
|
52
43
|
const nested = store.useState('nested');
|
|
53
44
|
const mounted = store.useState('mounted');
|
|
@@ -62,7 +53,7 @@ const DrawerBackdrop_DrawerBackdrop = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
62
53
|
store.context.backdropRef,
|
|
63
54
|
forwardedRef
|
|
64
55
|
],
|
|
65
|
-
stateAttributesMapping:
|
|
56
|
+
stateAttributesMapping: popupTransitionStateMapping,
|
|
66
57
|
props: [
|
|
67
58
|
{
|
|
68
59
|
role: 'presentation',
|
|
@@ -71,8 +62,8 @@ const DrawerBackdrop_DrawerBackdrop = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
71
62
|
pointerEvents: open ? void 0 : 'none',
|
|
72
63
|
userSelect: 'none',
|
|
73
64
|
WebkitUserSelect: 'none',
|
|
74
|
-
[
|
|
75
|
-
[
|
|
65
|
+
[DrawerBackdropCssVars_swipeProgress]: '0',
|
|
66
|
+
[DrawerPopupCssVars_swipeStrength]: '1'
|
|
76
67
|
}
|
|
77
68
|
},
|
|
78
69
|
elementProps
|
|
@@ -98,12 +89,10 @@ const DrawerContent_DrawerContent = /*#__PURE__*/ __rspack_external_react.forwar
|
|
|
98
89
|
if ("production" !== process.env.NODE_ENV) DrawerContent_DrawerContent.displayName = "DrawerContent";
|
|
99
90
|
const DrawerProviderContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
100
91
|
if ("production" !== process.env.NODE_ENV) DrawerProviderContext.displayName = "DrawerProviderContext";
|
|
101
|
-
function useDrawerProviderContext(
|
|
102
|
-
|
|
103
|
-
if (false === optional && void 0 === context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: DrawerProviderContext is missing. Use <Drawer.Provider>.' : esm_formatErrorMessage(91));
|
|
104
|
-
return context;
|
|
92
|
+
function useDrawerProviderContext() {
|
|
93
|
+
return __rspack_external_react.useContext(DrawerProviderContext);
|
|
105
94
|
}
|
|
106
|
-
const
|
|
95
|
+
const stateAttributesMapping = {
|
|
107
96
|
active (value) {
|
|
108
97
|
if (value) return {
|
|
109
98
|
'data-active': ''
|
|
@@ -115,7 +104,7 @@ const DrawerIndent_stateAttributesMapping = {
|
|
|
115
104
|
};
|
|
116
105
|
const DrawerIndent_DrawerIndent = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
117
106
|
const { render, className, style, ...elementProps } = componentProps;
|
|
118
|
-
const providerContext = useDrawerProviderContext(
|
|
107
|
+
const providerContext = useDrawerProviderContext();
|
|
119
108
|
const active = providerContext?.active ?? false;
|
|
120
109
|
const visualStateStore = providerContext?.visualStateStore;
|
|
121
110
|
const indentRef = __rspack_external_react.useRef(null);
|
|
@@ -124,17 +113,17 @@ const DrawerIndent_DrawerIndent = /*#__PURE__*/ __rspack_external_react.forwardR
|
|
|
124
113
|
if (!element || !visualStateStore) return;
|
|
125
114
|
const syncVisualState = ()=>{
|
|
126
115
|
const { swipeProgress, frontmostHeight } = visualStateStore.getSnapshot();
|
|
127
|
-
if (swipeProgress <= 0) element.style.setProperty(
|
|
128
|
-
else element.style.setProperty(
|
|
129
|
-
if (frontmostHeight <= 0) element.style.removeProperty(
|
|
130
|
-
else element.style.setProperty(
|
|
116
|
+
if (swipeProgress <= 0) element.style.setProperty(DrawerBackdropCssVars_swipeProgress, '0');
|
|
117
|
+
else element.style.setProperty(DrawerBackdropCssVars_swipeProgress, `${swipeProgress}`);
|
|
118
|
+
if (frontmostHeight <= 0) element.style.removeProperty(DrawerPopupCssVars_height);
|
|
119
|
+
else element.style.setProperty(DrawerPopupCssVars_height, `${frontmostHeight}px`);
|
|
131
120
|
};
|
|
132
121
|
syncVisualState();
|
|
133
122
|
const unsubscribe = visualStateStore.subscribe(syncVisualState);
|
|
134
123
|
return ()=>{
|
|
135
124
|
unsubscribe();
|
|
136
|
-
element.style.setProperty(
|
|
137
|
-
element.style.removeProperty(
|
|
125
|
+
element.style.setProperty(DrawerBackdropCssVars_swipeProgress, '0');
|
|
126
|
+
element.style.removeProperty(DrawerPopupCssVars_height);
|
|
138
127
|
};
|
|
139
128
|
}, [
|
|
140
129
|
visualStateStore
|
|
@@ -151,12 +140,12 @@ const DrawerIndent_DrawerIndent = /*#__PURE__*/ __rspack_external_react.forwardR
|
|
|
151
140
|
props: [
|
|
152
141
|
{
|
|
153
142
|
style: {
|
|
154
|
-
[
|
|
143
|
+
[DrawerBackdropCssVars_swipeProgress]: '0'
|
|
155
144
|
}
|
|
156
145
|
},
|
|
157
146
|
elementProps
|
|
158
147
|
],
|
|
159
|
-
stateAttributesMapping:
|
|
148
|
+
stateAttributesMapping: stateAttributesMapping
|
|
160
149
|
});
|
|
161
150
|
});
|
|
162
151
|
if ("production" !== process.env.NODE_ENV) DrawerIndent_DrawerIndent.displayName = "DrawerIndent";
|
|
@@ -172,7 +161,7 @@ const DrawerIndentBackground_stateAttributesMapping = {
|
|
|
172
161
|
};
|
|
173
162
|
const DrawerIndentBackground_DrawerIndentBackground = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
174
163
|
const { render, className, style, ...elementProps } = componentProps;
|
|
175
|
-
const providerContext = useDrawerProviderContext(
|
|
164
|
+
const providerContext = useDrawerProviderContext();
|
|
176
165
|
const active = providerContext?.active ?? false;
|
|
177
166
|
const state = {
|
|
178
167
|
active
|
|
@@ -185,26 +174,24 @@ const DrawerIndentBackground_DrawerIndentBackground = /*#__PURE__*/ __rspack_ext
|
|
|
185
174
|
});
|
|
186
175
|
});
|
|
187
176
|
if ("production" !== process.env.NODE_ENV) DrawerIndentBackground_DrawerIndentBackground.displayName = "DrawerIndentBackground";
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
DrawerPopupDataAttributes["nestedDrawerOpen"] = "data-nested-drawer-open";
|
|
195
|
-
DrawerPopupDataAttributes["nestedDrawerSwiping"] = "data-nested-drawer-swiping";
|
|
196
|
-
DrawerPopupDataAttributes["swipeDismiss"] = "data-swipe-dismiss";
|
|
197
|
-
DrawerPopupDataAttributes["swipeDirection"] = "data-swipe-direction";
|
|
198
|
-
DrawerPopupDataAttributes["swiping"] = "data-swiping";
|
|
199
|
-
return DrawerPopupDataAttributes;
|
|
200
|
-
}({});
|
|
177
|
+
const expanded = 'data-expanded';
|
|
178
|
+
const DrawerPopupDataAttributes_nestedDrawerOpen = 'data-nested-drawer-open';
|
|
179
|
+
const nestedDrawerSwiping = 'data-nested-drawer-swiping';
|
|
180
|
+
const swipeDismiss = 'data-swipe-dismiss';
|
|
181
|
+
const DrawerPopupDataAttributes_swipeDirection = 'data-swipe-direction';
|
|
182
|
+
const DrawerPopupDataAttributes_swiping = 'data-swiping';
|
|
201
183
|
const DrawerRootContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
202
184
|
if ("production" !== process.env.NODE_ENV) DrawerRootContext.displayName = "DrawerRootContext";
|
|
203
185
|
function useDrawerRootContext(optional) {
|
|
204
186
|
const drawerRootContext = __rspack_external_react.useContext(DrawerRootContext);
|
|
205
|
-
if (
|
|
187
|
+
if (true !== optional && void 0 === drawerRootContext) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: DrawerRootContext is missing. Drawer parts must be placed within <Drawer.Root>.' : utils_formatErrorMessage(90));
|
|
206
188
|
return drawerRootContext;
|
|
207
189
|
}
|
|
190
|
+
function getSnapPointSwipeMovement(baseOffset, movementValue) {
|
|
191
|
+
const nextOffset = baseOffset + movementValue;
|
|
192
|
+
if (nextOffset >= 0) return movementValue;
|
|
193
|
+
return -Math.sqrt(-nextOffset) - baseOffset;
|
|
194
|
+
}
|
|
208
195
|
function resolveSnapPointValue(snapPoint, viewportHeight, rootFontSize) {
|
|
209
196
|
if (!Number.isFinite(viewportHeight) || viewportHeight <= 0) return null;
|
|
210
197
|
if ('number' == typeof snapPoint) {
|
|
@@ -223,20 +210,20 @@ function resolveSnapPointValue(snapPoint, viewportHeight, rootFontSize) {
|
|
|
223
210
|
}
|
|
224
211
|
return null;
|
|
225
212
|
}
|
|
226
|
-
function
|
|
227
|
-
let
|
|
213
|
+
function closestSnapPointIndex(values, target) {
|
|
214
|
+
let closestIndex = -1;
|
|
228
215
|
let closestDistance = 1 / 0;
|
|
229
|
-
for
|
|
230
|
-
const distance = Math.abs(
|
|
216
|
+
for(let index = 0; index < values.length; index += 1){
|
|
217
|
+
const distance = Math.abs(values[index] - target);
|
|
231
218
|
if (distance < closestDistance) {
|
|
232
219
|
closestDistance = distance;
|
|
233
|
-
|
|
220
|
+
closestIndex = index;
|
|
234
221
|
}
|
|
235
222
|
}
|
|
236
|
-
return
|
|
223
|
+
return closestIndex;
|
|
237
224
|
}
|
|
238
225
|
function useDrawerSnapPoints() {
|
|
239
|
-
const
|
|
226
|
+
const store = useDialogRootContext();
|
|
240
227
|
const { snapPoints, activeSnapPoint, setActiveSnapPoint, popupHeight } = useDrawerRootContext();
|
|
241
228
|
const viewportElement = store.useState('viewportElement');
|
|
242
229
|
const [viewportHeight, setViewportHeight] = __rspack_external_react.useState(0);
|
|
@@ -244,8 +231,7 @@ function useDrawerSnapPoints() {
|
|
|
244
231
|
const measureViewportHeight = useStableCallback(()=>{
|
|
245
232
|
const doc = ownerDocument(viewportElement);
|
|
246
233
|
const html = doc.documentElement;
|
|
247
|
-
|
|
248
|
-
if (!viewportElement) setViewportHeight(html.clientHeight);
|
|
234
|
+
setViewportHeight(viewportElement ? viewportElement.offsetHeight : html.clientHeight);
|
|
249
235
|
const fontSize = parseFloat(getComputedStyle(html).fontSize);
|
|
250
236
|
if (Number.isFinite(fontSize)) setRootFontSize(fontSize);
|
|
251
237
|
});
|
|
@@ -264,10 +250,9 @@ function useDrawerSnapPoints() {
|
|
|
264
250
|
const resolvedSnapPoints = __rspack_external_react.useMemo(()=>{
|
|
265
251
|
if (!snapPoints || 0 === snapPoints.length || viewportHeight <= 0 || popupHeight <= 0) return [];
|
|
266
252
|
const maxHeight = Math.min(popupHeight, viewportHeight);
|
|
267
|
-
if (!Number.isFinite(maxHeight) || maxHeight <= 0) return [];
|
|
268
253
|
const resolved = snapPoints.map((value)=>{
|
|
269
254
|
const resolvedHeight = resolveSnapPointValue(value, viewportHeight, rootFontSize);
|
|
270
|
-
if (null === resolvedHeight
|
|
255
|
+
if (null === resolvedHeight) return null;
|
|
271
256
|
const clampedHeight = clamp(resolvedHeight, 0, maxHeight);
|
|
272
257
|
return {
|
|
273
258
|
value,
|
|
@@ -295,15 +280,14 @@ function useDrawerSnapPoints() {
|
|
|
295
280
|
viewportHeight
|
|
296
281
|
]);
|
|
297
282
|
const resolvedActiveSnapPoint = __rspack_external_react.useMemo(()=>{
|
|
298
|
-
if (void 0 === activeSnapPoint) return resolvedSnapPoints[0];
|
|
299
283
|
if (null === activeSnapPoint) return;
|
|
300
284
|
const exactMatch = resolvedSnapPoints.find((point)=>Object.is(point.value, activeSnapPoint));
|
|
301
285
|
if (exactMatch) return exactMatch;
|
|
302
286
|
const maxHeight = Math.min(popupHeight, viewportHeight);
|
|
303
287
|
const resolvedHeight = resolveSnapPointValue(activeSnapPoint, viewportHeight, rootFontSize);
|
|
304
|
-
if (null === resolvedHeight
|
|
288
|
+
if (null === resolvedHeight) return;
|
|
305
289
|
const clampedHeight = clamp(resolvedHeight, 0, maxHeight);
|
|
306
|
-
return
|
|
290
|
+
return resolvedSnapPoints[closestSnapPointIndex(resolvedSnapPoints.map((point)=>point.height), clampedHeight)];
|
|
307
291
|
}, [
|
|
308
292
|
activeSnapPoint,
|
|
309
293
|
popupHeight,
|
|
@@ -323,19 +307,17 @@ function useDrawerSnapPoints() {
|
|
|
323
307
|
}
|
|
324
308
|
const DrawerViewportContext = /*#__PURE__*/ __rspack_external_react.createContext(null);
|
|
325
309
|
if ("production" !== process.env.NODE_ENV) DrawerViewportContext.displayName = "DrawerViewportContext";
|
|
326
|
-
function useDrawerViewportContext(
|
|
327
|
-
|
|
328
|
-
if (false === optional && null === context) throw new Error("production" !== process.env.NODE_ENV ? 'Base UI: DrawerViewportContext is missing. Drawer parts must be placed within <Drawer.Viewport>.' : esm_formatErrorMessage(92));
|
|
329
|
-
return context;
|
|
310
|
+
function useDrawerViewportContext() {
|
|
311
|
+
return __rspack_external_react.useContext(DrawerViewportContext);
|
|
330
312
|
}
|
|
331
313
|
let drawerSwipeVarsRegistered = false;
|
|
332
314
|
function removeCSSVariableInheritance() {
|
|
333
315
|
if (drawerSwipeVarsRegistered) return;
|
|
334
316
|
if ("u" > typeof CSS && 'registerProperty' in CSS) {
|
|
335
317
|
[
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
318
|
+
swipeMovementX,
|
|
319
|
+
swipeMovementY,
|
|
320
|
+
snapPointOffset
|
|
339
321
|
].forEach((name)=>{
|
|
340
322
|
try {
|
|
341
323
|
CSS.registerProperty({
|
|
@@ -348,11 +330,11 @@ function removeCSSVariableInheritance() {
|
|
|
348
330
|
});
|
|
349
331
|
[
|
|
350
332
|
{
|
|
351
|
-
name:
|
|
333
|
+
name: DrawerBackdropCssVars_swipeProgress,
|
|
352
334
|
initialValue: '0'
|
|
353
335
|
},
|
|
354
336
|
{
|
|
355
|
-
name:
|
|
337
|
+
name: DrawerPopupCssVars_swipeStrength,
|
|
356
338
|
initialValue: '1'
|
|
357
339
|
}
|
|
358
340
|
].forEach(({ name, initialValue })=>{
|
|
@@ -369,37 +351,37 @@ function removeCSSVariableInheritance() {
|
|
|
369
351
|
drawerSwipeVarsRegistered = true;
|
|
370
352
|
}
|
|
371
353
|
const DrawerPopup_stateAttributesMapping = {
|
|
372
|
-
...
|
|
373
|
-
...transitionStatusMapping,
|
|
354
|
+
...popupTransitionStateMapping,
|
|
374
355
|
expanded (value) {
|
|
375
356
|
return value ? {
|
|
376
|
-
[
|
|
357
|
+
[expanded]: ''
|
|
377
358
|
} : null;
|
|
378
359
|
},
|
|
379
360
|
nestedDrawerOpen (value) {
|
|
380
361
|
return value ? {
|
|
381
|
-
[
|
|
362
|
+
[DrawerPopupDataAttributes_nestedDrawerOpen]: ''
|
|
382
363
|
} : null;
|
|
383
364
|
},
|
|
384
365
|
nestedDrawerSwiping (value) {
|
|
385
366
|
return value ? {
|
|
386
|
-
[
|
|
367
|
+
[nestedDrawerSwiping]: ''
|
|
387
368
|
} : null;
|
|
388
369
|
},
|
|
389
370
|
swipeDirection (value) {
|
|
390
|
-
return
|
|
391
|
-
[
|
|
392
|
-
}
|
|
371
|
+
return {
|
|
372
|
+
[DrawerPopupDataAttributes_swipeDirection]: value
|
|
373
|
+
};
|
|
393
374
|
},
|
|
394
375
|
swiping (value) {
|
|
395
376
|
return value ? {
|
|
396
|
-
[
|
|
377
|
+
[DrawerPopupDataAttributes_swiping]: ''
|
|
397
378
|
} : null;
|
|
398
379
|
}
|
|
399
380
|
};
|
|
400
381
|
const DrawerPopup_DrawerPopup = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
401
382
|
const { render, className, style, finalFocus, initialFocus, ...elementProps } = componentProps;
|
|
402
|
-
const
|
|
383
|
+
const store = useDialogRootContext();
|
|
384
|
+
const popupRef = store.context.popupRef;
|
|
403
385
|
const { swipeDirection, frontmostHeight, hasNestedDrawer, nestedSwiping, nestedSwipeProgressStore, onPopupHeightChange, notifyParentFrontmostHeight, notifyParentHasNestedDrawer } = useDrawerRootContext();
|
|
404
386
|
const descriptionElementId = store.useState("descriptionElementId");
|
|
405
387
|
const disablePointerDismissal = store.useState('disablePointerDismissal');
|
|
@@ -416,7 +398,7 @@ const DrawerPopup_DrawerPopup = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
416
398
|
const role = store.useState('role');
|
|
417
399
|
const floatingId = floatingRootContext.useState('floatingId');
|
|
418
400
|
const popupId = elementProps.id ?? floatingId;
|
|
419
|
-
const swipe = useDrawerViewportContext(
|
|
401
|
+
const swipe = useDrawerViewportContext();
|
|
420
402
|
useDialogPortalContext();
|
|
421
403
|
const { snapPoints, activeSnapPoint, activeSnapPointOffset } = useDrawerSnapPoints();
|
|
422
404
|
const nestedDrawerOpen = nestedOpenDrawerCount > 0;
|
|
@@ -433,7 +415,7 @@ const DrawerPopup_DrawerPopup = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
433
415
|
swipe
|
|
434
416
|
]);
|
|
435
417
|
const measureHeight = useStableCallback(()=>{
|
|
436
|
-
const popupElement =
|
|
418
|
+
const popupElement = popupRef.current;
|
|
437
419
|
if (!popupElement) return;
|
|
438
420
|
const offsetHeight = popupElement.offsetHeight;
|
|
439
421
|
if (popupHeightRef.current > 0 && frontmostHeight > popupHeightRef.current && offsetHeight > popupHeightRef.current) return;
|
|
@@ -457,7 +439,7 @@ const DrawerPopup_DrawerPopup = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
457
439
|
onPopupHeightChange(0);
|
|
458
440
|
return;
|
|
459
441
|
}
|
|
460
|
-
const popupElement =
|
|
442
|
+
const popupElement = popupRef.current;
|
|
461
443
|
if (!popupElement) return;
|
|
462
444
|
removeCSSVariableInheritance();
|
|
463
445
|
measureHeight();
|
|
@@ -472,29 +454,28 @@ const DrawerPopup_DrawerPopup = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
472
454
|
mounted,
|
|
473
455
|
nestedDrawerOpen,
|
|
474
456
|
onPopupHeightChange,
|
|
475
|
-
|
|
457
|
+
popupRef
|
|
476
458
|
]);
|
|
477
459
|
useIsoLayoutEffect(()=>{
|
|
478
|
-
const popupRef = store.context.popupRef;
|
|
479
460
|
const syncNestedSwipeProgress = ()=>{
|
|
480
461
|
const popupElement = popupRef.current;
|
|
481
462
|
if (!popupElement) return;
|
|
482
463
|
const progress = nestedSwipeProgressStore.getSnapshot();
|
|
483
|
-
if (progress > 0) popupElement.style.setProperty(
|
|
484
|
-
else popupElement.style.setProperty(
|
|
464
|
+
if (progress > 0) popupElement.style.setProperty(DrawerBackdropCssVars_swipeProgress, `${progress}`);
|
|
465
|
+
else popupElement.style.setProperty(DrawerBackdropCssVars_swipeProgress, '0');
|
|
485
466
|
};
|
|
486
467
|
syncNestedSwipeProgress();
|
|
487
468
|
const unsubscribe = nestedSwipeProgressStore.subscribe(syncNestedSwipeProgress);
|
|
469
|
+
const popupElement = popupRef.current;
|
|
488
470
|
return ()=>{
|
|
489
471
|
unsubscribe();
|
|
490
|
-
|
|
491
|
-
if (popupElement) popupElement.style.setProperty(DrawerBackdropCssVars_DrawerBackdropCssVars.swipeProgress, '0');
|
|
472
|
+
if (popupElement) popupElement.style.setProperty(DrawerBackdropCssVars_swipeProgress, '0');
|
|
492
473
|
};
|
|
493
474
|
}, [
|
|
494
475
|
nestedSwipeProgressStore,
|
|
495
|
-
|
|
476
|
+
popupRef
|
|
496
477
|
]);
|
|
497
|
-
|
|
478
|
+
useIsoLayoutEffect(()=>{
|
|
498
479
|
if (!open) return;
|
|
499
480
|
notifyParentFrontmostHeight?.(frontmostHeight);
|
|
500
481
|
return ()=>{
|
|
@@ -505,7 +486,7 @@ const DrawerPopup_DrawerPopup = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
505
486
|
open,
|
|
506
487
|
notifyParentFrontmostHeight
|
|
507
488
|
]);
|
|
508
|
-
|
|
489
|
+
useIsoLayoutEffect(()=>{
|
|
509
490
|
if (!notifyParentHasNestedDrawer) return;
|
|
510
491
|
const present = open || 'ending' === transitionStatus;
|
|
511
492
|
notifyParentHasNestedDrawer(present);
|
|
@@ -519,12 +500,12 @@ const DrawerPopup_DrawerPopup = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
519
500
|
]);
|
|
520
501
|
useOpenChangeComplete({
|
|
521
502
|
open,
|
|
522
|
-
ref:
|
|
503
|
+
ref: popupRef,
|
|
523
504
|
onComplete () {
|
|
524
505
|
if (open) store.context.onOpenChangeComplete?.(true);
|
|
525
506
|
}
|
|
526
507
|
});
|
|
527
|
-
const resolvedInitialFocus = void 0 === initialFocus ?
|
|
508
|
+
const resolvedInitialFocus = void 0 === initialFocus ? popupRef : initialFocus;
|
|
528
509
|
const setPopupElement = store.useStateSetter('popupElement');
|
|
529
510
|
const state = {
|
|
530
511
|
open,
|
|
@@ -545,19 +526,12 @@ const DrawerPopup_DrawerPopup = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
545
526
|
let dragStyles = swipe ? swipe.getDragStyles() : EMPTY_OBJECT;
|
|
546
527
|
if (shouldApplySnapPoints && 'down' === swipeDirection) {
|
|
547
528
|
const baseOffset = activeSnapPointOffset ?? 0;
|
|
548
|
-
const movementValue = Number.parseFloat(String(dragStyles[
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const dampedMovement = dampedOffset - baseOffset;
|
|
555
|
-
dragStyles = {
|
|
556
|
-
...dragStyles,
|
|
557
|
-
transform: void 0,
|
|
558
|
-
[DrawerPopupCssVars_DrawerPopupCssVars.swipeMovementY]: `${dampedMovement}px`
|
|
559
|
-
};
|
|
560
|
-
} else dragStyles = {
|
|
529
|
+
const movementValue = Number.parseFloat(String(dragStyles[swipeMovementY]));
|
|
530
|
+
dragStyles = swiping && Number.isFinite(movementValue) ? {
|
|
531
|
+
...dragStyles,
|
|
532
|
+
transform: void 0,
|
|
533
|
+
[swipeMovementY]: `${getSnapPointSwipeMovement(baseOffset, movementValue)}px`
|
|
534
|
+
} : {
|
|
561
535
|
...dragStyles,
|
|
562
536
|
transform: void 0
|
|
563
537
|
};
|
|
@@ -578,19 +552,19 @@ const DrawerPopup_DrawerPopup = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
578
552
|
},
|
|
579
553
|
style: {
|
|
580
554
|
...dragStyles,
|
|
581
|
-
[
|
|
582
|
-
[
|
|
583
|
-
[
|
|
584
|
-
[
|
|
585
|
-
[
|
|
586
|
-
[
|
|
555
|
+
[DrawerBackdropCssVars_swipeProgress]: '0',
|
|
556
|
+
[nestedDrawers]: nestedOpenDrawerCount,
|
|
557
|
+
[DrawerPopupCssVars_height]: popupHeightCssVarValue,
|
|
558
|
+
[snapPointOffset]: 'number' == typeof snapPointOffsetValue ? `${snapPointOffsetValue}px` : '0px',
|
|
559
|
+
[DrawerPopupCssVars_frontmostHeight]: frontmostHeight ? `${frontmostHeight}px` : void 0,
|
|
560
|
+
[DrawerPopupCssVars_swipeStrength]: 'number' == typeof swipeStrength && Number.isFinite(swipeStrength) && swipeStrength > 0 ? `${swipeStrength}` : '1'
|
|
587
561
|
}
|
|
588
562
|
},
|
|
589
563
|
elementProps
|
|
590
564
|
],
|
|
591
565
|
ref: [
|
|
592
566
|
forwardedRef,
|
|
593
|
-
|
|
567
|
+
popupRef,
|
|
594
568
|
setPopupElement
|
|
595
569
|
],
|
|
596
570
|
stateAttributesMapping: DrawerPopup_stateAttributesMapping
|
|
@@ -608,29 +582,26 @@ const DrawerPopup_DrawerPopup = /*#__PURE__*/ __rspack_external_react.forwardRef
|
|
|
608
582
|
});
|
|
609
583
|
});
|
|
610
584
|
if ("production" !== process.env.NODE_ENV) DrawerPopup_DrawerPopup.displayName = "DrawerPopup";
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
DrawerSwipeAreaDataAttributes["swiping"] = "data-swiping";
|
|
617
|
-
return DrawerSwipeAreaDataAttributes;
|
|
618
|
-
}({});
|
|
585
|
+
const DrawerSwipeAreaDataAttributes_open = CommonPopupDataAttributes_open;
|
|
586
|
+
const DrawerSwipeAreaDataAttributes_closed = CommonPopupDataAttributes_closed;
|
|
587
|
+
const DrawerSwipeAreaDataAttributes_disabled = 'data-disabled';
|
|
588
|
+
const DrawerSwipeAreaDataAttributes_swipeDirection = 'data-swipe-direction';
|
|
589
|
+
const DrawerSwipeAreaDataAttributes_swiping = 'data-swiping';
|
|
619
590
|
const DEFAULT_SWIPE_OPEN_RATIO = 0.5;
|
|
620
591
|
const MIN_SWIPE_START_DISTANCE = 1;
|
|
621
592
|
const VELOCITY_THRESHOLD = 0.1;
|
|
622
593
|
const FALLBACK_SWIPE_OPEN_THRESHOLD = 40;
|
|
623
594
|
const SWIPE_AREA_OPEN_HOOK = {
|
|
624
|
-
[
|
|
595
|
+
[DrawerSwipeAreaDataAttributes_open]: ''
|
|
625
596
|
};
|
|
626
597
|
const SWIPE_AREA_CLOSED_HOOK = {
|
|
627
|
-
[
|
|
598
|
+
[DrawerSwipeAreaDataAttributes_closed]: ''
|
|
628
599
|
};
|
|
629
600
|
const SWIPE_AREA_SWIPING_HOOK = {
|
|
630
|
-
[
|
|
601
|
+
[DrawerSwipeAreaDataAttributes_swiping]: ''
|
|
631
602
|
};
|
|
632
603
|
const SWIPE_AREA_DISABLED_HOOK = {
|
|
633
|
-
[
|
|
604
|
+
[DrawerSwipeAreaDataAttributes_disabled]: ''
|
|
634
605
|
};
|
|
635
606
|
const DrawerSwipeArea_stateAttributesMapping = {
|
|
636
607
|
open (value) {
|
|
@@ -640,9 +611,9 @@ const DrawerSwipeArea_stateAttributesMapping = {
|
|
|
640
611
|
return value ? SWIPE_AREA_SWIPING_HOOK : null;
|
|
641
612
|
},
|
|
642
613
|
swipeDirection (value) {
|
|
643
|
-
return
|
|
644
|
-
[
|
|
645
|
-
}
|
|
614
|
+
return {
|
|
615
|
+
[DrawerSwipeAreaDataAttributes_swipeDirection]: value
|
|
616
|
+
};
|
|
646
617
|
},
|
|
647
618
|
disabled (value) {
|
|
648
619
|
return value ? SWIPE_AREA_DISABLED_HOOK : null;
|
|
@@ -659,11 +630,10 @@ function resolveTouchAction(direction) {
|
|
|
659
630
|
}
|
|
660
631
|
const DrawerSwipeArea_DrawerSwipeArea = /*#__PURE__*/ __rspack_external_react.forwardRef(function(componentProps, forwardedRef) {
|
|
661
632
|
const { render, className, style, disabled = false, swipeDirection: swipeDirectionProp, ...elementProps } = componentProps;
|
|
662
|
-
const
|
|
663
|
-
const { swipeDirection, frontmostHeight } = useDrawerRootContext();
|
|
664
|
-
const providerContext = useDrawerProviderContext(
|
|
633
|
+
const store = useDialogRootContext();
|
|
634
|
+
const { swipeDirection, frontmostHeight, swipeAreaActiveRef } = useDrawerRootContext();
|
|
635
|
+
const providerContext = useDrawerProviderContext();
|
|
665
636
|
const [swipeActive, setSwipeActive] = __rspack_external_react.useState(false);
|
|
666
|
-
const releaseDismissTimeout = useTimeout();
|
|
667
637
|
const swipeAreaRef = __rspack_external_react.useRef(null);
|
|
668
638
|
const swipeStartEventRef = __rspack_external_react.useRef(null);
|
|
669
639
|
const openedBySwipeRef = __rspack_external_react.useRef(false);
|
|
@@ -673,9 +643,20 @@ const DrawerSwipeArea_DrawerSwipeArea = /*#__PURE__*/ __rspack_external_react.fo
|
|
|
673
643
|
});
|
|
674
644
|
const closedOffsetRef = __rspack_external_react.useRef(null);
|
|
675
645
|
const appliedSwipeStylesRef = __rspack_external_react.useRef(false);
|
|
646
|
+
const swipePopupElementRef = __rspack_external_react.useRef(null);
|
|
647
|
+
const swipeBackdropElementRef = __rspack_external_react.useRef(null);
|
|
676
648
|
const popupTransitionRef = __rspack_external_react.useRef(null);
|
|
649
|
+
const releaseGuardCleanupRef = __rspack_external_react.useRef(NOOP);
|
|
677
650
|
const swipeAreaId = useBaseUiId(componentProps.id);
|
|
678
651
|
const registerTrigger = useTriggerRegistration(swipeAreaId, store);
|
|
652
|
+
useIsoLayoutEffect(()=>{
|
|
653
|
+
registerTrigger(swipeAreaRef.current);
|
|
654
|
+
return ()=>registerTrigger(null);
|
|
655
|
+
}, [
|
|
656
|
+
registerTrigger,
|
|
657
|
+
swipeAreaId,
|
|
658
|
+
store
|
|
659
|
+
]);
|
|
679
660
|
const open = store.useState('open');
|
|
680
661
|
const resetDragDelta = useStableCallback(()=>{
|
|
681
662
|
dragDeltaRef.current.x = 0;
|
|
@@ -685,27 +666,36 @@ const DrawerSwipeArea_DrawerSwipeArea = /*#__PURE__*/ __rspack_external_react.fo
|
|
|
685
666
|
const dismissDirection = oppositeSwipeDirection[resolvedSwipeDirection];
|
|
686
667
|
const enabled = !disabled && (!open || swipeActive);
|
|
687
668
|
function disableDismissForSwipe() {
|
|
688
|
-
|
|
669
|
+
releaseGuardCleanupRef.current();
|
|
689
670
|
store.context.outsidePressEnabledRef.current = false;
|
|
690
671
|
}
|
|
691
|
-
|
|
692
|
-
|
|
672
|
+
const enableDismissAfterRelease = useStableCallback(()=>{
|
|
673
|
+
releaseGuardCleanupRef.current();
|
|
674
|
+
const doc = ownerDocument(swipeAreaRef.current);
|
|
675
|
+
function restore(event) {
|
|
676
|
+
if (event?.type === 'click' && 0 !== event.detail && !isVirtualClick(event)) return;
|
|
677
|
+
releaseGuardCleanupRef.current = NOOP;
|
|
678
|
+
doc.removeEventListener('pointerdown', restore, true);
|
|
679
|
+
doc.removeEventListener('click', restore, true);
|
|
693
680
|
store.context.outsidePressEnabledRef.current = true;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
681
|
+
}
|
|
682
|
+
releaseGuardCleanupRef.current = restore;
|
|
683
|
+
doc.addEventListener('pointerdown', restore, true);
|
|
684
|
+
doc.addEventListener('click', restore, true);
|
|
685
|
+
});
|
|
686
|
+
function getPopupSize(popupElement) {
|
|
699
687
|
const isHorizontal = 'left' === dismissDirection || 'right' === dismissDirection;
|
|
700
688
|
const size = isHorizontal ? popupElement.offsetWidth : popupElement.offsetHeight;
|
|
701
689
|
if (size <= 0) return null;
|
|
702
690
|
return size;
|
|
703
691
|
}
|
|
704
|
-
function
|
|
705
|
-
const offset = resolvePopupSize();
|
|
706
|
-
if (null == offset) return null;
|
|
692
|
+
function resolvePopupSize() {
|
|
707
693
|
const popupElement = store.context.popupRef.current;
|
|
708
|
-
|
|
694
|
+
return popupElement ? getPopupSize(popupElement) : null;
|
|
695
|
+
}
|
|
696
|
+
function resolveClosedOffset(popupElement) {
|
|
697
|
+
const offset = getPopupSize(popupElement);
|
|
698
|
+
if (null == offset) return null;
|
|
709
699
|
const isHorizontal = 'left' === dismissDirection || 'right' === dismissDirection;
|
|
710
700
|
const transform = getElementTransform(popupElement);
|
|
711
701
|
const transformOffset = isHorizontal ? transform.x : transform.y;
|
|
@@ -718,13 +708,12 @@ const DrawerSwipeArea_DrawerSwipeArea = /*#__PURE__*/ __rspack_external_react.fo
|
|
|
718
708
|
return popupSize * DEFAULT_SWIPE_OPEN_RATIO;
|
|
719
709
|
}
|
|
720
710
|
function applySwipeMovement() {
|
|
721
|
-
if (!swipeActive) return;
|
|
722
711
|
const popupElement = store.context.popupRef.current;
|
|
723
712
|
if (!popupElement) return;
|
|
724
713
|
if (!store.select('open') || !store.select('mounted')) return;
|
|
725
|
-
if (null == closedOffsetRef.current) closedOffsetRef.current = resolveClosedOffset();
|
|
714
|
+
if (null == closedOffsetRef.current) closedOffsetRef.current = resolveClosedOffset(popupElement);
|
|
726
715
|
const closedOffset = closedOffsetRef.current;
|
|
727
|
-
if (
|
|
716
|
+
if (null === closedOffset) return;
|
|
728
717
|
const { x, y } = dragDeltaRef.current;
|
|
729
718
|
const displacement = getDisplacement(resolvedSwipeDirection, x, y);
|
|
730
719
|
const clampedDisplacement = Math.max(0, displacement);
|
|
@@ -737,55 +726,59 @@ const DrawerSwipeArea_DrawerSwipeArea = /*#__PURE__*/ __rspack_external_react.fo
|
|
|
737
726
|
const movementY = isHorizontal ? 0 : movement;
|
|
738
727
|
const openProgress = Math.max(0, Math.min(1, clampedDisplacement / closedOffset));
|
|
739
728
|
const backdropProgress = Math.max(0, Math.min(1, 1 - openProgress));
|
|
740
|
-
popupElement.style.setProperty(
|
|
741
|
-
popupElement.style.setProperty(
|
|
742
|
-
popupElement.setAttribute(
|
|
729
|
+
popupElement.style.setProperty(swipeMovementX, `${movementX}px`);
|
|
730
|
+
popupElement.style.setProperty(swipeMovementY, `${movementY}px`);
|
|
731
|
+
popupElement.setAttribute(DrawerPopupDataAttributes_swiping, '');
|
|
732
|
+
swipePopupElementRef.current = popupElement;
|
|
743
733
|
if (null === popupTransitionRef.current) popupTransitionRef.current = popupElement.style.transition;
|
|
744
734
|
popupElement.style.transition = 'none';
|
|
745
735
|
const backdropElement = store.context.backdropRef.current;
|
|
746
736
|
if (backdropElement) {
|
|
747
|
-
backdropElement.setAttribute(
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
737
|
+
backdropElement.setAttribute(DrawerPopupDataAttributes_swiping, '');
|
|
738
|
+
swipeBackdropElementRef.current = backdropElement;
|
|
739
|
+
backdropElement.style.setProperty(DrawerBackdropCssVars_swipeProgress, `${backdropProgress}`);
|
|
740
|
+
if (openProgress > 0 && frontmostHeight > 0) backdropElement.style.setProperty(DrawerPopupCssVars_height, `${frontmostHeight}px`);
|
|
741
|
+
else backdropElement.style.removeProperty(DrawerPopupCssVars_height);
|
|
751
742
|
}
|
|
752
743
|
providerContext?.visualStateStore.set({
|
|
753
744
|
swipeProgress: openProgress,
|
|
754
745
|
frontmostHeight: openProgress > 0 ? frontmostHeight : 0
|
|
755
746
|
});
|
|
756
747
|
appliedSwipeStylesRef.current = true;
|
|
748
|
+
swipeAreaActiveRef.current = true;
|
|
757
749
|
}
|
|
758
750
|
const clearSwipeStyles = useStableCallback(()=>{
|
|
759
|
-
const popupElement =
|
|
760
|
-
if (popupElement
|
|
761
|
-
popupElement.style.removeProperty(
|
|
762
|
-
popupElement.style.removeProperty(
|
|
763
|
-
popupElement.removeAttribute(
|
|
751
|
+
const popupElement = swipePopupElementRef.current;
|
|
752
|
+
if (popupElement) {
|
|
753
|
+
popupElement.style.removeProperty(swipeMovementX);
|
|
754
|
+
popupElement.style.removeProperty(swipeMovementY);
|
|
755
|
+
popupElement.removeAttribute(DrawerPopupDataAttributes_swiping);
|
|
764
756
|
}
|
|
765
757
|
if (popupElement && null !== popupTransitionRef.current) {
|
|
766
758
|
popupElement.style.transition = popupTransitionRef.current;
|
|
767
759
|
popupTransitionRef.current = null;
|
|
768
760
|
}
|
|
769
|
-
const backdropElement =
|
|
761
|
+
const backdropElement = swipeBackdropElementRef.current;
|
|
770
762
|
if (backdropElement) {
|
|
771
|
-
backdropElement.removeAttribute(
|
|
772
|
-
backdropElement.style.setProperty(
|
|
773
|
-
backdropElement.style.removeProperty(
|
|
763
|
+
backdropElement.removeAttribute(DrawerPopupDataAttributes_swiping);
|
|
764
|
+
backdropElement.style.setProperty(DrawerBackdropCssVars_swipeProgress, '0');
|
|
765
|
+
backdropElement.style.removeProperty(DrawerPopupCssVars_height);
|
|
774
766
|
}
|
|
775
767
|
providerContext?.visualStateStore.set({
|
|
776
768
|
swipeProgress: 0,
|
|
777
769
|
frontmostHeight: 0
|
|
778
770
|
});
|
|
779
771
|
appliedSwipeStylesRef.current = false;
|
|
772
|
+
swipePopupElementRef.current = null;
|
|
773
|
+
swipeBackdropElementRef.current = null;
|
|
774
|
+
swipeAreaActiveRef.current = false;
|
|
780
775
|
});
|
|
781
776
|
function openDrawer(event) {
|
|
782
|
-
if (store.select('open')) return;
|
|
783
777
|
openedBySwipeRef.current = true;
|
|
784
|
-
store.setOpen(true, createChangeEventDetails("swipe", event, swipeAreaRef.current
|
|
778
|
+
store.setOpen(true, createChangeEventDetails("swipe", event, swipeAreaRef.current));
|
|
785
779
|
}
|
|
786
780
|
function closeDrawer(event) {
|
|
787
|
-
|
|
788
|
-
store.setOpen(false, createChangeEventDetails("swipe", event, swipeAreaRef.current ?? void 0));
|
|
781
|
+
store.setOpen(false, createChangeEventDetails("swipe", event, swipeAreaRef.current));
|
|
789
782
|
}
|
|
790
783
|
function resetSwipeInteractionState() {
|
|
791
784
|
swipeStartEventRef.current = null;
|
|
@@ -807,8 +800,8 @@ const DrawerSwipeArea_DrawerSwipeArea = /*#__PURE__*/ __rspack_external_react.fo
|
|
|
807
800
|
elementRef: swipeAreaRef,
|
|
808
801
|
trackDrag: false,
|
|
809
802
|
movementCssVars: {
|
|
810
|
-
x:
|
|
811
|
-
y:
|
|
803
|
+
x: swipeMovementX,
|
|
804
|
+
y: swipeMovementY
|
|
812
805
|
},
|
|
813
806
|
onSwipeStart (event) {
|
|
814
807
|
disableDismissForSwipe();
|
|
@@ -824,20 +817,20 @@ const DrawerSwipeArea_DrawerSwipeArea = /*#__PURE__*/ __rspack_external_react.fo
|
|
|
824
817
|
dragDeltaRef.current.y = details.deltaY;
|
|
825
818
|
if (details.direction !== resolvedSwipeDirection) return;
|
|
826
819
|
const displacement = getDisplacement(resolvedSwipeDirection, details.deltaX, details.deltaY);
|
|
827
|
-
if (displacement < MIN_SWIPE_START_DISTANCE
|
|
828
|
-
if (!openedBySwipeRef.current) openDrawer(swipeStartEventRef.current);
|
|
820
|
+
if (!openedBySwipeRef.current && displacement < MIN_SWIPE_START_DISTANCE) return;
|
|
821
|
+
if (!openedBySwipeRef.current && !store.select('open')) openDrawer(swipeStartEventRef.current);
|
|
829
822
|
applySwipeMovement();
|
|
830
823
|
},
|
|
831
824
|
onRelease ({ event, direction, deltaX, deltaY, releaseVelocityX, releaseVelocityY }) {
|
|
832
825
|
const displacement = getDisplacement(resolvedSwipeDirection, deltaX, deltaY);
|
|
833
826
|
const releaseVelocity = getDisplacement(resolvedSwipeDirection, releaseVelocityX, releaseVelocityY);
|
|
834
827
|
const threshold = resolveSwipeOpenThreshold();
|
|
835
|
-
const hasEnoughDistance =
|
|
828
|
+
const hasEnoughDistance = displacement >= threshold;
|
|
836
829
|
const hasEnoughVelocity = releaseVelocity >= VELOCITY_THRESHOLD;
|
|
837
|
-
const shouldOpen =
|
|
830
|
+
const shouldOpen = direction === resolvedSwipeDirection && (hasEnoughDistance || hasEnoughVelocity) && !disabled;
|
|
838
831
|
if (shouldOpen) {
|
|
839
832
|
if (!store.select('open')) openDrawer(event);
|
|
840
|
-
} else if (openedBySwipeRef.current) closeDrawer(event);
|
|
833
|
+
} else if (openedBySwipeRef.current && store.select('open')) closeDrawer(event);
|
|
841
834
|
finishSwipeInteraction();
|
|
842
835
|
return false;
|
|
843
836
|
},
|
|
@@ -846,8 +839,12 @@ const DrawerSwipeArea_DrawerSwipeArea = /*#__PURE__*/ __rspack_external_react.fo
|
|
|
846
839
|
const swipePointerProps = swipe.getPointerProps();
|
|
847
840
|
const swipeTouchProps = swipe.getTouchProps();
|
|
848
841
|
const resetSwipe = swipe.reset;
|
|
849
|
-
|
|
842
|
+
useIsoLayoutEffect(()=>{
|
|
843
|
+
if (swipeActive && appliedSwipeStylesRef.current) applySwipeMovement();
|
|
844
|
+
});
|
|
845
|
+
useIsoLayoutEffect(()=>{
|
|
850
846
|
if (!enabled) {
|
|
847
|
+
if (swipeActive) enableDismissAfterRelease();
|
|
851
848
|
resetSwipe();
|
|
852
849
|
resetDragDelta();
|
|
853
850
|
clearSwipeStyles();
|
|
@@ -855,11 +852,14 @@ const DrawerSwipeArea_DrawerSwipeArea = /*#__PURE__*/ __rspack_external_react.fo
|
|
|
855
852
|
}
|
|
856
853
|
}, [
|
|
857
854
|
clearSwipeStyles,
|
|
855
|
+
enableDismissAfterRelease,
|
|
858
856
|
enabled,
|
|
859
857
|
resetDragDelta,
|
|
860
|
-
resetSwipe
|
|
858
|
+
resetSwipe,
|
|
859
|
+
swipeActive
|
|
861
860
|
]);
|
|
862
861
|
__rspack_external_react.useEffect(()=>()=>{
|
|
862
|
+
releaseGuardCleanupRef.current();
|
|
863
863
|
store.context.outsidePressEnabledRef.current = true;
|
|
864
864
|
}, [
|
|
865
865
|
store
|
|
@@ -913,6 +913,12 @@ const DrawerSwipeArea_DrawerSwipeArea = /*#__PURE__*/ __rspack_external_react.fo
|
|
|
913
913
|
});
|
|
914
914
|
});
|
|
915
915
|
if ("production" !== process.env.NODE_ENV) DrawerSwipeArea_DrawerSwipeArea.displayName = "DrawerSwipeArea";
|
|
916
|
+
const nestedDialogOpen = 'data-nested-dialog-open';
|
|
917
|
+
const DrawerVirtualKeyboardContext = /*#__PURE__*/ __rspack_external_react.createContext(void 0);
|
|
918
|
+
if ("production" !== process.env.NODE_ENV) DrawerVirtualKeyboardContext.displayName = "DrawerVirtualKeyboardContext";
|
|
919
|
+
function useDrawerVirtualKeyboardContext() {
|
|
920
|
+
return __rspack_external_react.useContext(DrawerVirtualKeyboardContext);
|
|
921
|
+
}
|
|
916
922
|
const MIN_SWIPE_THRESHOLD = 10;
|
|
917
923
|
const FAST_SWIPE_VELOCITY = 0.5;
|
|
918
924
|
const SNAP_VELOCITY_THRESHOLD = 0.5;
|
|
@@ -924,12 +930,20 @@ const MIN_SWIPE_RELEASE_DURATION_MS = 80;
|
|
|
924
930
|
const MAX_SWIPE_RELEASE_DURATION_MS = 360;
|
|
925
931
|
const MIN_SWIPE_RELEASE_SCALAR = 0.1;
|
|
926
932
|
const MAX_SWIPE_RELEASE_SCALAR = 1;
|
|
933
|
+
const AXIS_LOCK_SLOP = 6;
|
|
934
|
+
const AXIS_LOCK_BIAS = 2;
|
|
927
935
|
const DRAWER_CONTENT_SELECTOR = `[${DRAWER_CONTENT_ATTRIBUTE}]`;
|
|
936
|
+
const AXIS_SWIPE_IGNORE_SELECTORS = {
|
|
937
|
+
horizontal: `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}="x"]`,
|
|
938
|
+
vertical: `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}="y"]`
|
|
939
|
+
};
|
|
928
940
|
const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forwardRef(function(props, forwardedRef) {
|
|
929
941
|
const { render, className, style, children, ...elementProps } = props;
|
|
930
|
-
const
|
|
931
|
-
const
|
|
932
|
-
const
|
|
942
|
+
const store = useDialogRootContext();
|
|
943
|
+
const popupRef = store.context.popupRef;
|
|
944
|
+
const backdropRef = store.context.backdropRef;
|
|
945
|
+
const { swipeDirection, notifyParentSwipingChange, notifyParentSwipeProgressChange, frontmostHeight, snapToSequentialPoints, swipeAreaActiveRef } = useDrawerRootContext();
|
|
946
|
+
const providerContext = useDrawerProviderContext();
|
|
933
947
|
const { snapPoints, resolvedSnapPoints, activeSnapPoint, activeSnapPointOffset, setActiveSnapPoint, popupHeight } = useDrawerSnapPoints();
|
|
934
948
|
const open = store.useState('open');
|
|
935
949
|
const mounted = store.useState('mounted');
|
|
@@ -946,26 +960,19 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
946
960
|
const pendingSwipeCloseSnapPointRef = __rspack_external_react.useRef(void 0);
|
|
947
961
|
const resetSwipeRef = __rspack_external_react.useRef(null);
|
|
948
962
|
const controlledDismissFrame = useAnimationFrame();
|
|
963
|
+
const swipingRef = __rspack_external_react.useRef(false);
|
|
949
964
|
const nestedSwipeActiveRef = __rspack_external_react.useRef(false);
|
|
950
965
|
const lastPointerTypeRef = __rspack_external_react.useRef('');
|
|
951
966
|
const ignoreNextTouchStartFromPenRef = __rspack_external_react.useRef(false);
|
|
952
967
|
const ignoreTouchSwipeRef = __rspack_external_react.useRef(false);
|
|
953
968
|
const touchScrollStateRef = __rspack_external_react.useRef(null);
|
|
969
|
+
const virtualKeyboard = useDrawerVirtualKeyboardContext();
|
|
954
970
|
const snapPointRange = __rspack_external_react.useMemo(()=>{
|
|
955
|
-
if (!snapPoints || snapPoints.length < 2) return null;
|
|
956
|
-
|
|
957
|
-
if (resolvedSnapPoints.length < 2) return null;
|
|
958
|
-
const offsets = resolvedSnapPoints.map((point)=>point.offset).filter((offset)=>Number.isFinite(offset)).sort((a, b)=>a - b);
|
|
959
|
-
if (offsets.length < 2) return null;
|
|
971
|
+
if (!snapPoints || snapPoints.length < 2 || resolvedSnapPoints.length < 2 || 'down' !== swipeDirection && 'up' !== swipeDirection) return null;
|
|
972
|
+
const offsets = resolvedSnapPoints.map((point)=>point.offset).sort((a, b)=>a - b);
|
|
960
973
|
const minOffset = offsets[0];
|
|
961
974
|
const nextOffset = offsets[1];
|
|
962
|
-
const
|
|
963
|
-
let range = nextOffset - minOffset;
|
|
964
|
-
if (!Number.isFinite(range) || range <= 0) {
|
|
965
|
-
const fallbackRange = maxOffset - minOffset;
|
|
966
|
-
if (!Number.isFinite(fallbackRange) || fallbackRange <= 0) return null;
|
|
967
|
-
range = fallbackRange;
|
|
968
|
-
}
|
|
975
|
+
const range = nextOffset - minOffset;
|
|
969
976
|
return {
|
|
970
977
|
minOffset,
|
|
971
978
|
range
|
|
@@ -998,11 +1005,12 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
998
1005
|
swipeDirection
|
|
999
1006
|
]);
|
|
1000
1007
|
const setSwipeDismissed = useStableCallback((dismissed)=>{
|
|
1001
|
-
|
|
1008
|
+
popupRef.current?.toggleAttribute(swipeDismiss, dismissed);
|
|
1009
|
+
backdropRef.current?.toggleAttribute(swipeDismiss, dismissed);
|
|
1002
1010
|
});
|
|
1003
1011
|
const clearSwipeRelease = useStableCallback(()=>{
|
|
1004
1012
|
setSwipeDismissed(false);
|
|
1005
|
-
|
|
1013
|
+
popupRef.current?.removeAttribute(TransitionStatusDataAttributes_endingStyle);
|
|
1006
1014
|
setSwipeRelease(null);
|
|
1007
1015
|
});
|
|
1008
1016
|
const finishNestedSwipe = useStableCallback(()=>{
|
|
@@ -1010,7 +1018,7 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1010
1018
|
nestedSwipeActiveRef.current = false;
|
|
1011
1019
|
notifyParentSwipingChange?.(false);
|
|
1012
1020
|
});
|
|
1013
|
-
const applySwipeProgress = useStableCallback((
|
|
1021
|
+
const applySwipeProgress = useStableCallback((resolvedProgress, shouldTrackProgress, notifyParent)=>{
|
|
1014
1022
|
const isActive = open && !nested && shouldTrackProgress;
|
|
1015
1023
|
const swipeProgress = isActive ? resolvedProgress : 0;
|
|
1016
1024
|
const nestedSwipeProgress = open && shouldTrackProgress ? resolvedProgress : 0;
|
|
@@ -1022,50 +1030,33 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1022
1030
|
swipeProgress,
|
|
1023
1031
|
frontmostHeight: swipeProgress > 0 ? frontmostHeight : 0
|
|
1024
1032
|
});
|
|
1025
|
-
const backdropElement =
|
|
1033
|
+
const backdropElement = backdropRef.current;
|
|
1026
1034
|
if (!backdropElement) return;
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
}
|
|
1032
|
-
backdropElement.style.setProperty(DrawerBackdropCssVars_DrawerBackdropCssVars.swipeProgress, `${swipeProgress}`);
|
|
1033
|
-
if (frontmostHeight > 0) backdropElement.style.setProperty(DrawerPopupCssVars_DrawerPopupCssVars.height, `${frontmostHeight}px`);
|
|
1034
|
-
else backdropElement.style.removeProperty(DrawerPopupCssVars_DrawerPopupCssVars.height);
|
|
1035
|
+
const showProgress = isActive && swipeProgress > 0;
|
|
1036
|
+
backdropElement.style.setProperty(DrawerBackdropCssVars_swipeProgress, showProgress ? `${swipeProgress}` : '0');
|
|
1037
|
+
if (showProgress && frontmostHeight > 0) backdropElement.style.setProperty(DrawerPopupCssVars_height, `${frontmostHeight}px`);
|
|
1038
|
+
else backdropElement.style.removeProperty(DrawerPopupCssVars_height);
|
|
1035
1039
|
});
|
|
1036
|
-
function resolveSwipeRelease(
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
const
|
|
1041
|
-
if (!Number.isFinite(size) || size <= 0) return null;
|
|
1042
|
-
const axisDelta = 'left' === direction || 'right' === direction ? deltaX : deltaY;
|
|
1043
|
-
const snapPointBaseOffset = snapPoints && snapPoints.length > 0 ? activeSnapPointOffset ?? 0 : 0;
|
|
1044
|
-
let baseOffset = 0;
|
|
1045
|
-
if ('down' === direction) baseOffset = snapPointBaseOffset;
|
|
1046
|
-
else if ('up' === direction) baseOffset = -snapPointBaseOffset;
|
|
1047
|
-
const translation = baseOffset + axisDelta;
|
|
1048
|
-
const translationAlongDirection = 'left' === direction || 'up' === direction ? -translation : translation;
|
|
1040
|
+
function resolveSwipeRelease(popupElement, direction, deltaX, deltaY, velocityX, velocityY, releaseVelocityX, releaseVelocityY) {
|
|
1041
|
+
const size = getBaseSwipeSize(popupElement, direction);
|
|
1042
|
+
if (size <= 0) return null;
|
|
1043
|
+
const snapPointBaseOffset = ('down' === direction || 'up' === direction) && snapPoints && snapPoints.length > 0 ? activeSnapPointOffset ?? 0 : 0;
|
|
1044
|
+
const translationAlongDirection = snapPointBaseOffset + getDisplacement(direction, deltaX, deltaY);
|
|
1049
1045
|
const remainingDistance = Math.max(0, size - translationAlongDirection);
|
|
1050
|
-
if (
|
|
1051
|
-
const
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1054
|
-
const directionalVelocity = 'left' === direction || 'up' === direction ? -resolvedVelocity : resolvedVelocity;
|
|
1055
|
-
if (!Number.isFinite(directionalVelocity) || directionalVelocity <= MIN_SWIPE_RELEASE_VELOCITY) return null;
|
|
1046
|
+
if (remainingDistance <= 0) return null;
|
|
1047
|
+
const releaseVelocity = getDisplacement(direction, releaseVelocityX, releaseVelocityY);
|
|
1048
|
+
const directionalVelocity = Math.abs(releaseVelocity) > 0 ? releaseVelocity : getDisplacement(direction, velocityX, velocityY);
|
|
1049
|
+
if (directionalVelocity <= MIN_SWIPE_RELEASE_VELOCITY) return null;
|
|
1056
1050
|
const clampedVelocity = clamp(directionalVelocity, MIN_SWIPE_RELEASE_VELOCITY, MAX_SWIPE_RELEASE_VELOCITY);
|
|
1057
1051
|
const durationMs = clamp(remainingDistance / clampedVelocity, MIN_SWIPE_RELEASE_DURATION_MS, MAX_SWIPE_RELEASE_DURATION_MS);
|
|
1058
|
-
if (!Number.isFinite(durationMs)) return null;
|
|
1059
1052
|
const normalizedDuration = (durationMs - MIN_SWIPE_RELEASE_DURATION_MS) / (MAX_SWIPE_RELEASE_DURATION_MS - MIN_SWIPE_RELEASE_DURATION_MS);
|
|
1060
|
-
|
|
1061
|
-
if (!Number.isFinite(durationScalar) || durationScalar <= 0) return null;
|
|
1062
|
-
return durationScalar;
|
|
1053
|
+
return MIN_SWIPE_RELEASE_SCALAR + normalizedDuration * (MAX_SWIPE_RELEASE_SCALAR - MIN_SWIPE_RELEASE_SCALAR);
|
|
1063
1054
|
}
|
|
1064
1055
|
function updateNestedSwipeActive(details) {
|
|
1065
1056
|
if (nestedSwipeActiveRef.current || !details) return;
|
|
1066
1057
|
const direction = details.direction ?? swipeDirection;
|
|
1067
|
-
const delta =
|
|
1068
|
-
if (
|
|
1058
|
+
const delta = getDisplacement(direction, details.deltaX, details.deltaY);
|
|
1059
|
+
if (Math.abs(delta) < MIN_SWIPE_THRESHOLD) return;
|
|
1069
1060
|
nestedSwipeActiveRef.current = true;
|
|
1070
1061
|
notifyParentSwipingChange?.(true);
|
|
1071
1062
|
}
|
|
@@ -1076,13 +1067,12 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1076
1067
|
ignoreSelectorWhenTouch: false,
|
|
1077
1068
|
ignoreScrollableAncestors: true,
|
|
1078
1069
|
movementCssVars: {
|
|
1079
|
-
x:
|
|
1080
|
-
y:
|
|
1070
|
+
x: swipeMovementX,
|
|
1071
|
+
y: swipeMovementY
|
|
1081
1072
|
},
|
|
1082
1073
|
onSwipeStart (event) {
|
|
1083
|
-
if ('touches' in event || '
|
|
1084
|
-
const popupElement =
|
|
1085
|
-
if (!popupElement) return;
|
|
1074
|
+
if ('touches' in event || 'touch' === event.pointerType) return;
|
|
1075
|
+
const popupElement = popupRef.current;
|
|
1086
1076
|
const doc = ownerDocument(popupElement);
|
|
1087
1077
|
const selection = doc.getSelection?.();
|
|
1088
1078
|
if (!selection || selection.isCollapsed) return;
|
|
@@ -1092,6 +1082,7 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1092
1082
|
selection.removeAllRanges();
|
|
1093
1083
|
},
|
|
1094
1084
|
onSwipingChange (swiping) {
|
|
1085
|
+
swipingRef.current = swiping;
|
|
1095
1086
|
setBackdropSwipingAttribute(store.context.backdropRef.current, swiping);
|
|
1096
1087
|
if (!swiping && !notifyParentSwipeProgressChange) finishNestedSwipe();
|
|
1097
1088
|
},
|
|
@@ -1101,108 +1092,103 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1101
1092
|
canStart (position, details) {
|
|
1102
1093
|
const popupElement = store.context.popupRef.current;
|
|
1103
1094
|
if (!popupElement) return false;
|
|
1104
|
-
const doc = popupElement.ownerDocument;
|
|
1105
|
-
const elementAtPoint = getElementAtPoint(doc, position.x, position.y);
|
|
1106
|
-
if (!elementAtPoint || !contains(popupElement, elementAtPoint)) return false;
|
|
1107
1095
|
const nativeEvent = details.nativeEvent;
|
|
1108
|
-
const touchLike = 'touches' in nativeEvent || '
|
|
1096
|
+
const touchLike = 'touches' in nativeEvent || 'touch' === nativeEvent.pointerType;
|
|
1097
|
+
const touchState = touchLike ? touchScrollStateRef.current : null;
|
|
1098
|
+
const doc = popupElement.ownerDocument;
|
|
1099
|
+
const elementAtPoint = getElementAtPoint(popupElement.getRootNode(), position.x, position.y);
|
|
1100
|
+
if (!touchState?.startedInPopup && !contains(popupElement, elementAtPoint)) return false;
|
|
1109
1101
|
if (touchLike && shouldIgnoreSwipeForTextSelection(doc, popupElement)) return false;
|
|
1110
|
-
if (
|
|
1102
|
+
if (touchState?.hasCrossAxisGestureTarget && !touchState.drawerAxisAttributed && true !== touchState.allowSwipe) return false;
|
|
1111
1103
|
return true;
|
|
1112
1104
|
},
|
|
1113
1105
|
onProgress (progress, details) {
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
const isDismissSwipe = void 0 === currentDirection || currentDirection === swipeDirection;
|
|
1106
|
+
const swiping = swipingRef.current;
|
|
1107
|
+
if (swiping) updateNestedSwipeActive(details);
|
|
1117
1108
|
const hasSnapPoints = Boolean(snapPoints && snapPoints.length > 0);
|
|
1118
|
-
|
|
1119
|
-
|
|
1109
|
+
if (swiping && 'down' === swipeDirection && hasSnapPoints && details) {
|
|
1110
|
+
const popupElement = store.context.popupRef.current;
|
|
1111
|
+
if (popupElement) {
|
|
1112
|
+
popupElement.style.removeProperty('transform');
|
|
1113
|
+
popupElement.style.setProperty(swipeMovementY, `${getSnapPointSwipeMovement(activeSnapPointOffset ?? 0, details.deltaY)}px`);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1120
1116
|
let resolvedProgress = progress;
|
|
1121
1117
|
if (snapPointRange && popupHeight > 0) {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
} else if (null !== snapPointProgress) resolvedProgress = snapPointProgress;
|
|
1127
|
-
else if ('down' === currentDirection || 'up' === currentDirection) {
|
|
1128
|
-
const displacement = progress * popupHeight;
|
|
1129
|
-
const baseOffset = activeSnapPointOffset ?? snapPointRange.minOffset;
|
|
1130
|
-
const nextOffset = 'down' === currentDirection ? baseOffset + displacement : baseOffset - displacement;
|
|
1131
|
-
resolvedProgress = clamp((nextOffset - snapPointRange.minOffset) / snapPointRange.range, 0, 1);
|
|
1132
|
-
}
|
|
1118
|
+
const baseOffset = activeSnapPointOffset ?? snapPointRange.minOffset;
|
|
1119
|
+
const offsetToProgress = (nextOffset)=>clamp((nextOffset - snapPointRange.minOffset) / snapPointRange.range, 0, 1);
|
|
1120
|
+
if (swiping && details && Number.isFinite(details.deltaY)) resolvedProgress = offsetToProgress(clamp(baseOffset + details.deltaY, 0, popupHeight));
|
|
1121
|
+
else if (null !== snapPointProgress) resolvedProgress = snapPointProgress;
|
|
1133
1122
|
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1123
|
+
if (!swiping) {
|
|
1124
|
+
notifyParentSwipeProgressChange?.(0);
|
|
1125
|
+
finishNestedSwipe();
|
|
1126
|
+
}
|
|
1127
|
+
applySwipeProgress(resolvedProgress, true, swiping);
|
|
1139
1128
|
},
|
|
1140
1129
|
onRelease ({ event, deltaX, deltaY, direction, velocityX, velocityY, releaseVelocityX, releaseVelocityY }) {
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
velocityX,
|
|
1145
|
-
velocityY,
|
|
1146
|
-
releaseVelocityX,
|
|
1147
|
-
releaseVelocityY
|
|
1148
|
-
};
|
|
1130
|
+
const popupElement = store.context.popupRef.current;
|
|
1131
|
+
if (!popupElement) return void clearSwipeRelease();
|
|
1132
|
+
const releasePopupElement = popupElement;
|
|
1149
1133
|
function startSwipeRelease(resolvedDirection) {
|
|
1150
|
-
const popupElement = store.context.popupRef.current;
|
|
1151
|
-
if (!popupElement) return;
|
|
1152
1134
|
finishNestedSwipe();
|
|
1153
1135
|
setSwipeDismissed(true);
|
|
1154
|
-
|
|
1155
|
-
|
|
1136
|
+
releasePopupElement.style.removeProperty('transition');
|
|
1137
|
+
releasePopupElement.setAttribute(TransitionStatusDataAttributes_endingStyle, '');
|
|
1156
1138
|
__rspack_external_react_dom_7136dc57.flushSync(()=>{
|
|
1157
|
-
setSwipeRelease(resolveSwipeRelease(
|
|
1158
|
-
direction: resolvedDirection,
|
|
1159
|
-
...swipeReleasePayload
|
|
1160
|
-
}));
|
|
1139
|
+
setSwipeRelease(resolveSwipeRelease(releasePopupElement, resolvedDirection, deltaX, deltaY, velocityX, velocityY, releaseVelocityX, releaseVelocityY));
|
|
1161
1140
|
});
|
|
1162
1141
|
}
|
|
1163
1142
|
if (!snapPoints || 0 === snapPoints.length) {
|
|
1164
1143
|
if (!direction) return void clearSwipeRelease();
|
|
1165
|
-
const
|
|
1166
|
-
if (!element) return void clearSwipeRelease();
|
|
1167
|
-
const baseThreshold = getBaseSwipeThreshold(element, direction);
|
|
1168
|
-
const delta = 'left' === direction || 'right' === direction ? deltaX : deltaY;
|
|
1169
|
-
if (!Number.isFinite(delta)) return void clearSwipeRelease();
|
|
1170
|
-
const directionalDelta = 'left' === direction || 'up' === direction ? -delta : delta;
|
|
1144
|
+
const directionalDelta = getDisplacement(direction, deltaX, deltaY);
|
|
1171
1145
|
if (directionalDelta <= 0) {
|
|
1172
1146
|
clearSwipeRelease();
|
|
1173
1147
|
return false;
|
|
1174
1148
|
}
|
|
1175
|
-
|
|
1176
|
-
const directionalVelocity = 'left' === direction || 'up' === direction ? -velocity : velocity;
|
|
1177
|
-
if (directionalVelocity >= FAST_SWIPE_VELOCITY && directionalDelta > 0) {
|
|
1149
|
+
if (getDisplacement(direction, velocityX, velocityY) >= FAST_SWIPE_VELOCITY) {
|
|
1178
1150
|
startSwipeRelease(direction);
|
|
1179
1151
|
return true;
|
|
1180
1152
|
}
|
|
1181
|
-
const shouldClose = directionalDelta >
|
|
1153
|
+
const shouldClose = directionalDelta > getBaseSwipeThreshold(releasePopupElement, direction);
|
|
1182
1154
|
if (shouldClose) startSwipeRelease(direction);
|
|
1183
1155
|
else clearSwipeRelease();
|
|
1184
1156
|
return shouldClose;
|
|
1185
1157
|
}
|
|
1186
1158
|
if ('down' !== swipeDirection && 'up' !== swipeDirection) return void clearSwipeRelease();
|
|
1187
|
-
if (!popupHeight
|
|
1159
|
+
if (!popupHeight) {
|
|
1160
|
+
clearSwipeRelease();
|
|
1161
|
+
return false;
|
|
1162
|
+
}
|
|
1163
|
+
if (0 === resolvedSnapPoints.length) return void clearSwipeRelease();
|
|
1188
1164
|
const dragDelta = 'down' === swipeDirection ? deltaY : -deltaY;
|
|
1189
|
-
if (!Number.isFinite(dragDelta)) return void clearSwipeRelease();
|
|
1190
1165
|
const dragDirection = Math.sign(dragDelta);
|
|
1191
1166
|
const releaseDirectionalVelocity = 'down' === swipeDirection ? releaseVelocityY : -releaseVelocityY;
|
|
1192
1167
|
const fallbackDirectionalVelocity = 'down' === swipeDirection ? velocityY : -velocityY;
|
|
1193
|
-
let resolvedDirectionalVelocity =
|
|
1194
|
-
if (0 !== dragDirection && Math.abs(dragDelta) >= MIN_SWIPE_THRESHOLD
|
|
1168
|
+
let resolvedDirectionalVelocity = releaseDirectionalVelocity;
|
|
1169
|
+
if (0 !== dragDirection && Math.abs(dragDelta) >= MIN_SWIPE_THRESHOLD) {
|
|
1195
1170
|
const velocityDirection = Math.sign(resolvedDirectionalVelocity);
|
|
1196
1171
|
if (0 !== velocityDirection && velocityDirection !== dragDirection) resolvedDirectionalVelocity = fallbackDirectionalVelocity;
|
|
1197
1172
|
}
|
|
1198
1173
|
const currentOffset = activeSnapPointOffset ?? 0;
|
|
1199
1174
|
const dragTargetOffset = clamp(currentOffset + dragDelta, 0, popupHeight);
|
|
1200
|
-
const velocityOffset =
|
|
1175
|
+
const velocityOffset = Math.abs(resolvedDirectionalVelocity) >= SNAP_VELOCITY_THRESHOLD ? clamp(resolvedDirectionalVelocity, -MAX_SNAP_VELOCITY, MAX_SNAP_VELOCITY) * SNAP_VELOCITY_MULTIPLIER : 0;
|
|
1201
1176
|
const targetOffset = snapToSequentialPoints ? dragTargetOffset : clamp(dragTargetOffset + velocityOffset, 0, popupHeight);
|
|
1202
1177
|
const snapPointEventDetails = createChangeEventDetails("swipe", event);
|
|
1203
|
-
const
|
|
1178
|
+
const settleInPlace = ()=>{
|
|
1179
|
+
applySwipeProgress(0, true, true);
|
|
1180
|
+
clearSwipeRelease();
|
|
1181
|
+
return false;
|
|
1182
|
+
};
|
|
1183
|
+
const settleOnSnapPoint = (snapPoint)=>{
|
|
1184
|
+
setActiveSnapPoint(snapPoint.value, snapPointEventDetails);
|
|
1185
|
+
return settleInPlace();
|
|
1186
|
+
};
|
|
1187
|
+
const closeFromSnapPoints = (fallbackSnapPoint)=>{
|
|
1188
|
+
if (!direction) return settleOnSnapPoint(fallbackSnapPoint);
|
|
1189
|
+
setActiveSnapPoint(null, snapPointEventDetails);
|
|
1190
|
+
if (snapPointEventDetails.isCanceled) return settleInPlace();
|
|
1204
1191
|
pendingSwipeCloseSnapPointRef.current = activeSnapPoint;
|
|
1205
|
-
setActiveSnapPoint?.(null, snapPointEventDetails);
|
|
1206
1192
|
startSwipeRelease(swipeDirection);
|
|
1207
1193
|
return true;
|
|
1208
1194
|
};
|
|
@@ -1210,28 +1196,9 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1210
1196
|
const orderedSnapPoints = [
|
|
1211
1197
|
...resolvedSnapPoints
|
|
1212
1198
|
].sort((first, second)=>first.offset - second.offset);
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
}
|
|
1217
|
-
let currentIndex = 0;
|
|
1218
|
-
let closestDistance = Math.abs(currentOffset - orderedSnapPoints[0].offset);
|
|
1219
|
-
for(let index = 1; index < orderedSnapPoints.length; index += 1){
|
|
1220
|
-
const distance = Math.abs(currentOffset - orderedSnapPoints[index].offset);
|
|
1221
|
-
if (distance < closestDistance) {
|
|
1222
|
-
closestDistance = distance;
|
|
1223
|
-
currentIndex = index;
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
let targetSnapPoint = orderedSnapPoints[0];
|
|
1227
|
-
closestDistance = Math.abs(targetOffset - targetSnapPoint.offset);
|
|
1228
|
-
for (const snapPoint of orderedSnapPoints){
|
|
1229
|
-
const distance = Math.abs(targetOffset - snapPoint.offset);
|
|
1230
|
-
if (distance < closestDistance) {
|
|
1231
|
-
closestDistance = distance;
|
|
1232
|
-
targetSnapPoint = snapPoint;
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1199
|
+
const orderedOffsets = orderedSnapPoints.map((point)=>point.offset);
|
|
1200
|
+
const currentIndex = closestSnapPointIndex(orderedOffsets, currentOffset);
|
|
1201
|
+
let targetSnapPoint = orderedSnapPoints[closestSnapPointIndex(orderedOffsets, targetOffset)];
|
|
1235
1202
|
const velocityDirection = Math.sign(resolvedDirectionalVelocity);
|
|
1236
1203
|
const shouldAdvance = 0 !== dragDirection && 0 !== velocityDirection && velocityDirection === dragDirection && Math.abs(resolvedDirectionalVelocity) >= SNAP_VELOCITY_THRESHOLD;
|
|
1237
1204
|
let effectiveTargetOffset = targetOffset;
|
|
@@ -1244,32 +1211,18 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1244
1211
|
targetSnapPoint = adjacentPoint;
|
|
1245
1212
|
effectiveTargetOffset = adjacentPoint.offset;
|
|
1246
1213
|
}
|
|
1247
|
-
} else if (dragDirection > 0) return closeFromSnapPoints();
|
|
1214
|
+
} else if (dragDirection > 0) return closeFromSnapPoints(targetSnapPoint);
|
|
1248
1215
|
}
|
|
1249
|
-
const
|
|
1250
|
-
const closeDistance = Math.abs(effectiveTargetOffset - closeOffset);
|
|
1216
|
+
const closeDistance = Math.abs(effectiveTargetOffset - popupHeight);
|
|
1251
1217
|
const snapDistance = Math.abs(effectiveTargetOffset - targetSnapPoint.offset);
|
|
1252
|
-
if (closeDistance < snapDistance) return closeFromSnapPoints();
|
|
1253
|
-
|
|
1254
|
-
clearSwipeRelease();
|
|
1255
|
-
return false;
|
|
1218
|
+
if (closeDistance < snapDistance) return closeFromSnapPoints(targetSnapPoint);
|
|
1219
|
+
return settleOnSnapPoint(targetSnapPoint);
|
|
1256
1220
|
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
if (distance < closestDistance) {
|
|
1263
|
-
closestDistance = distance;
|
|
1264
|
-
closestSnapPoint = snapPoint;
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
const closeOffset = popupHeight;
|
|
1268
|
-
const closeDistance = Math.abs(targetOffset - closeOffset);
|
|
1269
|
-
if (closeDistance < closestDistance) return closeFromSnapPoints();
|
|
1270
|
-
setActiveSnapPoint?.(closestSnapPoint.value, snapPointEventDetails);
|
|
1271
|
-
clearSwipeRelease();
|
|
1272
|
-
return false;
|
|
1221
|
+
const closestSnapPoint = resolvedSnapPoints[closestSnapPointIndex(resolvedSnapPoints.map((point)=>point.offset), targetOffset)];
|
|
1222
|
+
if (resolvedDirectionalVelocity >= FAST_SWIPE_VELOCITY && dragDelta > 0) return closeFromSnapPoints(closestSnapPoint);
|
|
1223
|
+
const closeDistance = Math.abs(targetOffset - popupHeight);
|
|
1224
|
+
if (closeDistance < Math.abs(targetOffset - closestSnapPoint.offset)) return closeFromSnapPoints(closestSnapPoint);
|
|
1225
|
+
return settleOnSnapPoint(closestSnapPoint);
|
|
1273
1226
|
},
|
|
1274
1227
|
onDismiss (event) {
|
|
1275
1228
|
visualStateStore?.set({
|
|
@@ -1278,14 +1231,14 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1278
1231
|
});
|
|
1279
1232
|
const backdropElement = store.context.backdropRef.current;
|
|
1280
1233
|
if (backdropElement) {
|
|
1281
|
-
backdropElement.style.setProperty(
|
|
1282
|
-
backdropElement.style.removeProperty(
|
|
1234
|
+
backdropElement.style.setProperty(DrawerBackdropCssVars_swipeProgress, '0');
|
|
1235
|
+
backdropElement.style.removeProperty(DrawerPopupCssVars_height);
|
|
1283
1236
|
}
|
|
1284
1237
|
const dismissEventDetails = createChangeEventDetails("swipe", event);
|
|
1285
1238
|
store.setOpen(false, dismissEventDetails);
|
|
1286
1239
|
if (dismissEventDetails.isCanceled) {
|
|
1287
1240
|
const pendingSnapPoint = pendingSwipeCloseSnapPointRef.current;
|
|
1288
|
-
if (void 0 !== pendingSnapPoint) setActiveSnapPoint
|
|
1241
|
+
if (void 0 !== pendingSnapPoint) setActiveSnapPoint(pendingSnapPoint, createChangeEventDetails("swipe", event));
|
|
1289
1242
|
pendingSwipeCloseSnapPointRef.current = void 0;
|
|
1290
1243
|
resetSwipeRef.current?.();
|
|
1291
1244
|
clearSwipeRelease();
|
|
@@ -1296,7 +1249,7 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1296
1249
|
controlledDismissFrame.request(()=>{
|
|
1297
1250
|
if (store.select('open')) {
|
|
1298
1251
|
const pendingSnapPoint = pendingSwipeCloseSnapPointRef.current;
|
|
1299
|
-
if (void 0 !== pendingSnapPoint) setActiveSnapPoint
|
|
1252
|
+
if (void 0 !== pendingSnapPoint) setActiveSnapPoint(pendingSnapPoint, createChangeEventDetails("swipe", savedEvent));
|
|
1300
1253
|
pendingSwipeCloseSnapPointRef.current = void 0;
|
|
1301
1254
|
clearSwipeRelease();
|
|
1302
1255
|
resetSwipeRef.current?.();
|
|
@@ -1310,52 +1263,52 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1310
1263
|
});
|
|
1311
1264
|
const swipePointerProps = swipe.getPointerProps();
|
|
1312
1265
|
const swipeTouchProps = swipe.getTouchProps();
|
|
1313
|
-
const resetSwipe = swipe
|
|
1266
|
+
const { moveNative: moveSwipeNative, reset: resetSwipe } = swipe;
|
|
1314
1267
|
resetSwipeRef.current = resetSwipe;
|
|
1315
1268
|
__rspack_external_react.useEffect(()=>{
|
|
1316
1269
|
const rootElement = viewportElement ?? popupElementState;
|
|
1317
|
-
if (!rootElement) return;
|
|
1270
|
+
if (!rootElement || !open || !mounted) return;
|
|
1318
1271
|
const resolvedRootElement = rootElement;
|
|
1319
1272
|
const doc = ownerDocument(resolvedRootElement);
|
|
1320
|
-
|
|
1321
|
-
function handleNativeTouchMove(event) {
|
|
1322
|
-
if (ignoreTouchSwipeRef.current) return;
|
|
1323
|
-
const touchState = touchScrollStateRef.current;
|
|
1324
|
-
const touch = event.touches[0];
|
|
1325
|
-
if (!touch || !touchState) return;
|
|
1273
|
+
function processTouchMove(event, touchState, touch) {
|
|
1326
1274
|
const drawerAxisDelta = isVerticalScrollAxis ? touch.clientY - touchState.lastY : touch.clientX - touchState.lastX;
|
|
1327
|
-
if (
|
|
1328
|
-
touchState.allowSwipe = false;
|
|
1329
|
-
updateTouchScrollPosition(touchState, touch);
|
|
1330
|
-
return;
|
|
1331
|
-
}
|
|
1332
|
-
if (2 === event.touches.length) return void updateTouchScrollPosition(touchState, touch);
|
|
1275
|
+
if (2 === event.touches.length) return;
|
|
1333
1276
|
const allowTouchMove = shouldIgnoreSwipeForTextSelection(doc, resolvedRootElement);
|
|
1334
|
-
if (allowTouchMove ||
|
|
1335
|
-
if (
|
|
1277
|
+
if (allowTouchMove || nestedDrawerOpen) return;
|
|
1278
|
+
if (shouldYieldTouchMove(touchState, event, touch, isVerticalScrollAxis)) return;
|
|
1336
1279
|
const scrollTarget = touchState.scrollTarget;
|
|
1337
1280
|
if (!scrollTarget || scrollTarget === doc.documentElement || scrollTarget === doc.body) {
|
|
1338
1281
|
if (event.cancelable) event.preventDefault();
|
|
1339
|
-
|
|
1282
|
+
event.stopPropagation();
|
|
1283
|
+
moveSwipeNative(event, resolvedRootElement);
|
|
1340
1284
|
return;
|
|
1341
1285
|
}
|
|
1342
|
-
|
|
1343
|
-
if (!hasScrollableContent) {
|
|
1286
|
+
if (!hasScrollableContentOnAxis(scrollTarget, scrollAxis)) {
|
|
1344
1287
|
if (event.cancelable) event.preventDefault();
|
|
1345
|
-
|
|
1288
|
+
event.stopPropagation();
|
|
1346
1289
|
return;
|
|
1347
1290
|
}
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
const canSwipeFromScrollEdge = canSwipeFromScrollEdgeOnMove(scrollTarget, scrollAxis, swipeDirection, delta);
|
|
1291
|
+
if (0 !== drawerAxisDelta) {
|
|
1292
|
+
const canSwipeFromScrollEdge = canSwipeFromScrollEdgeOnMove(scrollTarget, scrollAxis, swipeDirection, drawerAxisDelta);
|
|
1351
1293
|
if (touchState.allowSwipe) {
|
|
1352
1294
|
if (event.cancelable) event.preventDefault();
|
|
1353
|
-
} else if (event.cancelable
|
|
1295
|
+
} else if (event.cancelable && canSwipeFromScrollEdge) {
|
|
1354
1296
|
touchState.allowSwipe = true;
|
|
1355
1297
|
event.preventDefault();
|
|
1356
1298
|
} else touchState.allowSwipe = false;
|
|
1357
|
-
else touchState.allowSwipe = false;
|
|
1358
1299
|
}
|
|
1300
|
+
if (true === touchState.allowSwipe) {
|
|
1301
|
+
event.stopPropagation();
|
|
1302
|
+
moveSwipeNative(event, resolvedRootElement);
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
function handleNativeTouchMove(event) {
|
|
1306
|
+
virtualKeyboard?.onTouchMove(event);
|
|
1307
|
+
if (ignoreTouchSwipeRef.current) return;
|
|
1308
|
+
const touchState = touchScrollStateRef.current;
|
|
1309
|
+
const touch = event.touches[0];
|
|
1310
|
+
if (!touch || !touchState) return;
|
|
1311
|
+
processTouchMove(event, touchState, touch);
|
|
1359
1312
|
updateTouchScrollPosition(touchState, touch);
|
|
1360
1313
|
}
|
|
1361
1314
|
return addEventListener(doc, 'touchmove', handleNativeTouchMove, {
|
|
@@ -1370,16 +1323,13 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1370
1323
|
isVerticalScrollAxis,
|
|
1371
1324
|
scrollAxis,
|
|
1372
1325
|
swipeDirection,
|
|
1373
|
-
|
|
1326
|
+
moveSwipeNative,
|
|
1327
|
+
viewportElement,
|
|
1328
|
+
virtualKeyboard
|
|
1374
1329
|
]);
|
|
1375
|
-
|
|
1330
|
+
useIsoLayoutEffect(()=>{
|
|
1376
1331
|
if (!snapPointRange || swipe.swiping) return;
|
|
1377
|
-
|
|
1378
|
-
applySwipeProgress({
|
|
1379
|
-
resolvedProgress,
|
|
1380
|
-
shouldTrackProgress: true,
|
|
1381
|
-
notifyParent: false
|
|
1382
|
-
});
|
|
1332
|
+
applySwipeProgress(!open || nested ? 0 : snapPointProgress ?? 0, true, false);
|
|
1383
1333
|
}, [
|
|
1384
1334
|
applySwipeProgress,
|
|
1385
1335
|
frontmostHeight,
|
|
@@ -1392,7 +1342,7 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1392
1342
|
store,
|
|
1393
1343
|
visualStateStore
|
|
1394
1344
|
]);
|
|
1395
|
-
|
|
1345
|
+
useIsoLayoutEffect(()=>{
|
|
1396
1346
|
if (!notifyParentSwipeProgressChange) return;
|
|
1397
1347
|
if (!open) notifyParentSwipeProgressChange(0);
|
|
1398
1348
|
return ()=>{
|
|
@@ -1402,26 +1352,32 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1402
1352
|
notifyParentSwipeProgressChange,
|
|
1403
1353
|
open
|
|
1404
1354
|
]);
|
|
1405
|
-
|
|
1355
|
+
useIsoLayoutEffect(()=>{
|
|
1406
1356
|
if (open) {
|
|
1407
|
-
resetSwipe();
|
|
1357
|
+
if (!swipeAreaActiveRef.current) resetSwipe();
|
|
1408
1358
|
clearSwipeRelease();
|
|
1409
1359
|
}
|
|
1410
1360
|
}, [
|
|
1411
1361
|
clearSwipeRelease,
|
|
1412
1362
|
open,
|
|
1413
|
-
resetSwipe
|
|
1363
|
+
resetSwipe,
|
|
1364
|
+
swipeAreaActiveRef
|
|
1414
1365
|
]);
|
|
1415
|
-
|
|
1366
|
+
useIsoLayoutEffect(()=>{
|
|
1367
|
+
const backdropElement = backdropRef.current;
|
|
1368
|
+
return ()=>{
|
|
1416
1369
|
visualStateStore?.set({
|
|
1417
1370
|
swipeProgress: 0,
|
|
1418
1371
|
frontmostHeight: 0
|
|
1419
1372
|
});
|
|
1420
|
-
setBackdropSwipingAttribute(
|
|
1373
|
+
setBackdropSwipingAttribute(backdropElement, false);
|
|
1374
|
+
const currentBackdrop = backdropRef.current;
|
|
1375
|
+
if (currentBackdrop !== backdropElement) setBackdropSwipingAttribute(currentBackdrop, false);
|
|
1421
1376
|
finishNestedSwipe();
|
|
1422
|
-
}
|
|
1377
|
+
};
|
|
1378
|
+
}, [
|
|
1379
|
+
backdropRef,
|
|
1423
1380
|
finishNestedSwipe,
|
|
1424
|
-
store,
|
|
1425
1381
|
visualStateStore
|
|
1426
1382
|
]);
|
|
1427
1383
|
const swipeProviderValue = __rspack_external_react.useMemo(()=>({
|
|
@@ -1435,12 +1391,19 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1435
1391
|
swipe.swiping,
|
|
1436
1392
|
swipeRelease
|
|
1437
1393
|
]);
|
|
1438
|
-
function
|
|
1439
|
-
ignoreTouchSwipeRef.current =
|
|
1394
|
+
function resetTouchSwipeState(ignoreSwipe) {
|
|
1395
|
+
ignoreTouchSwipeRef.current = ignoreSwipe;
|
|
1440
1396
|
touchScrollStateRef.current = null;
|
|
1397
|
+
}
|
|
1398
|
+
function resetTouchTrackingState() {
|
|
1399
|
+
resetTouchSwipeState(false);
|
|
1441
1400
|
lastPointerTypeRef.current = '';
|
|
1442
1401
|
ignoreNextTouchStartFromPenRef.current = false;
|
|
1443
1402
|
}
|
|
1403
|
+
function handlePointerEnd(event) {
|
|
1404
|
+
lastPointerTypeRef.current = '';
|
|
1405
|
+
return 'touch' !== event.pointerType;
|
|
1406
|
+
}
|
|
1444
1407
|
return /*#__PURE__*/ jsx(DialogViewport_DialogViewport, {
|
|
1445
1408
|
ref: forwardedRef,
|
|
1446
1409
|
className: className,
|
|
@@ -1451,8 +1414,7 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1451
1414
|
lastPointerTypeRef.current = event.pointerType;
|
|
1452
1415
|
ignoreNextTouchStartFromPenRef.current = 'pen' === event.pointerType;
|
|
1453
1416
|
if (!open || !mounted || nestedDrawerOpen) return;
|
|
1454
|
-
const
|
|
1455
|
-
const elementAtPoint = getElementAtPoint(doc, event.clientX, event.clientY);
|
|
1417
|
+
const elementAtPoint = getElementAtPoint(event.currentTarget.getRootNode(), event.clientX, event.clientY);
|
|
1456
1418
|
if (isSwipeIgnoredTarget(elementAtPoint) || isDrawerContentTarget(elementAtPoint)) return;
|
|
1457
1419
|
if ('touch' === event.pointerType) return;
|
|
1458
1420
|
swipePointerProps.onPointerDown?.(event);
|
|
@@ -1462,56 +1424,32 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1462
1424
|
swipePointerProps.onPointerMove?.(event);
|
|
1463
1425
|
},
|
|
1464
1426
|
onPointerUp (event) {
|
|
1465
|
-
if (
|
|
1466
|
-
if ('touch' === event.pointerType) return;
|
|
1467
|
-
swipePointerProps.onPointerUp?.(event);
|
|
1427
|
+
if (handlePointerEnd(event)) swipePointerProps.onPointerUp?.(event);
|
|
1468
1428
|
},
|
|
1469
1429
|
onPointerCancel (event) {
|
|
1470
|
-
if (
|
|
1471
|
-
if ('touch' === event.pointerType) return;
|
|
1472
|
-
swipePointerProps.onPointerCancel?.(event);
|
|
1430
|
+
if (handlePointerEnd(event)) swipePointerProps.onPointerCancel?.(event);
|
|
1473
1431
|
},
|
|
1474
1432
|
onTouchStart (event) {
|
|
1475
1433
|
const startedFromPenPointerDown = 'pen' === lastPointerTypeRef.current && ignoreNextTouchStartFromPenRef.current;
|
|
1476
1434
|
if (startedFromPenPointerDown) {
|
|
1477
1435
|
ignoreNextTouchStartFromPenRef.current = false;
|
|
1478
|
-
|
|
1479
|
-
touchScrollStateRef.current = null;
|
|
1480
|
-
return;
|
|
1481
|
-
}
|
|
1482
|
-
if (!open || !mounted || nestedDrawerOpen) {
|
|
1483
|
-
ignoreTouchSwipeRef.current = false;
|
|
1484
|
-
touchScrollStateRef.current = null;
|
|
1436
|
+
resetTouchSwipeState(false);
|
|
1485
1437
|
return;
|
|
1486
1438
|
}
|
|
1439
|
+
if (!open || !mounted || nestedDrawerOpen) return void resetTouchSwipeState(false);
|
|
1487
1440
|
const touch = event.touches[0];
|
|
1488
1441
|
if (!touch) return;
|
|
1489
|
-
if (isReactTouchEventOnRangeInput(event))
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
return;
|
|
1493
|
-
}
|
|
1494
|
-
const doc = ownerDocument(event.currentTarget);
|
|
1495
|
-
const elementAtPoint = getElementAtPoint(doc, touch.clientX, touch.clientY);
|
|
1496
|
-
ignoreTouchSwipeRef.current = isSwipeIgnoredTarget(elementAtPoint);
|
|
1497
|
-
if (ignoreTouchSwipeRef.current) {
|
|
1498
|
-
touchScrollStateRef.current = null;
|
|
1499
|
-
return;
|
|
1500
|
-
}
|
|
1501
|
-
const rootElement = viewportElement ?? popupElementState;
|
|
1442
|
+
if (isReactTouchEventOnRangeInput(event)) return void resetTouchSwipeState(false);
|
|
1443
|
+
const rootElement = event.currentTarget;
|
|
1444
|
+
const elementAtPoint = getElementAtPoint(rootElement.getRootNode(), touch.clientX, touch.clientY);
|
|
1502
1445
|
const eventTarget = getTarget(event.nativeEvent);
|
|
1503
|
-
const target = isElement(eventTarget) ? eventTarget :
|
|
1504
|
-
if (
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
let hasCrossAxisScrollableContent = false;
|
|
1511
|
-
if (rootElement && target) {
|
|
1512
|
-
scrollTarget = findScrollableTouchTarget(target, rootElement, scrollAxis);
|
|
1513
|
-
hasCrossAxisScrollableContent = null != findScrollableTouchTarget(target, rootElement, crossScrollAxis);
|
|
1514
|
-
}
|
|
1446
|
+
const target = isElement(eventTarget) ? eventTarget : rootElement;
|
|
1447
|
+
if (!contains(rootElement, target)) return void resetTouchSwipeState(true);
|
|
1448
|
+
virtualKeyboard?.onTouchStart(event);
|
|
1449
|
+
if (closest(elementAtPoint, `${BASE_UI_SWIPE_IGNORE_SELECTOR}:not(${AXIS_SWIPE_IGNORE_SELECTORS[crossScrollAxis]})`)) return void resetTouchSwipeState(true);
|
|
1450
|
+
ignoreTouchSwipeRef.current = false;
|
|
1451
|
+
const scrollTarget = findScrollableTouchTarget(target, rootElement, scrollAxis);
|
|
1452
|
+
const hasCrossAxisGestureTarget = null != findScrollableTouchTarget(target, rootElement, crossScrollAxis) || null != closest(elementAtPoint, AXIS_SWIPE_IGNORE_SELECTORS[crossScrollAxis]);
|
|
1515
1453
|
let allowSwipe = null;
|
|
1516
1454
|
if (scrollTarget) {
|
|
1517
1455
|
const canSwipeFromEdge = isAtSwipeStartEdge(scrollTarget, scrollAxis, swipeDirection);
|
|
@@ -1522,30 +1460,26 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1522
1460
|
startY: touch.clientY,
|
|
1523
1461
|
lastX: touch.clientX,
|
|
1524
1462
|
lastY: touch.clientY,
|
|
1463
|
+
startedInPopup: contains(popupRef.current, elementAtPoint),
|
|
1525
1464
|
scrollTarget,
|
|
1526
|
-
|
|
1465
|
+
hasCrossAxisGestureTarget,
|
|
1527
1466
|
allowSwipe,
|
|
1528
|
-
preserveNativeCrossAxisScroll: false
|
|
1467
|
+
preserveNativeCrossAxisScroll: false,
|
|
1468
|
+
drawerAxisAttributed: false
|
|
1529
1469
|
};
|
|
1530
1470
|
swipeTouchProps.onTouchStart?.(event);
|
|
1531
1471
|
},
|
|
1532
|
-
onTouchMove (event) {
|
|
1533
|
-
if (ignoreTouchSwipeRef.current) return;
|
|
1534
|
-
if (isReactTouchEventOnRangeInput(event)) return;
|
|
1535
|
-
const touchState = touchScrollStateRef.current;
|
|
1536
|
-
if (touchState?.preserveNativeCrossAxisScroll) return;
|
|
1537
|
-
if (touchState?.allowSwipe === false || touchState?.scrollTarget != null && !touchState.allowSwipe) return;
|
|
1538
|
-
swipeTouchProps.onTouchMove?.(event);
|
|
1539
|
-
},
|
|
1540
1472
|
onTouchEnd (event) {
|
|
1473
|
+
virtualKeyboard?.onTouchEnd(event);
|
|
1541
1474
|
resetTouchTrackingState();
|
|
1542
1475
|
swipeTouchProps.onTouchEnd?.(event);
|
|
1543
1476
|
},
|
|
1544
1477
|
onTouchCancel (event) {
|
|
1478
|
+
virtualKeyboard?.onTouchCancel();
|
|
1545
1479
|
resetTouchTrackingState();
|
|
1546
1480
|
swipeTouchProps.onTouchCancel?.(event);
|
|
1547
1481
|
},
|
|
1548
|
-
[
|
|
1482
|
+
[nestedDialogOpen]: void 0
|
|
1549
1483
|
}),
|
|
1550
1484
|
children: /*#__PURE__*/ jsx(DrawerViewportContext.Provider, {
|
|
1551
1485
|
value: swipeProviderValue,
|
|
@@ -1554,35 +1488,25 @@ const DrawerViewport_DrawerViewport = /*#__PURE__*/ __rspack_external_react.forw
|
|
|
1554
1488
|
});
|
|
1555
1489
|
});
|
|
1556
1490
|
if ("production" !== process.env.NODE_ENV) DrawerViewport_DrawerViewport.displayName = "DrawerViewport";
|
|
1557
|
-
function setSwipeDismissedElements(popupElement, backdropElement, dismissed) {
|
|
1558
|
-
if (dismissed) {
|
|
1559
|
-
popupElement?.setAttribute(DrawerPopupDataAttributes_DrawerPopupDataAttributes.swipeDismiss, '');
|
|
1560
|
-
backdropElement?.setAttribute(DrawerPopupDataAttributes_DrawerPopupDataAttributes.swipeDismiss, '');
|
|
1561
|
-
return;
|
|
1562
|
-
}
|
|
1563
|
-
popupElement?.removeAttribute(DrawerPopupDataAttributes_DrawerPopupDataAttributes.swipeDismiss);
|
|
1564
|
-
backdropElement?.removeAttribute(DrawerPopupDataAttributes_DrawerPopupDataAttributes.swipeDismiss);
|
|
1565
|
-
}
|
|
1566
1491
|
function setBackdropSwipingAttribute(backdropElement, swiping) {
|
|
1567
|
-
|
|
1568
|
-
if (swiping) return void backdropElement.setAttribute(DrawerPopupDataAttributes_DrawerPopupDataAttributes.swiping, '');
|
|
1569
|
-
backdropElement.removeAttribute(DrawerPopupDataAttributes_DrawerPopupDataAttributes.swiping);
|
|
1492
|
+
backdropElement?.toggleAttribute(DrawerPopupDataAttributes_swiping, swiping);
|
|
1570
1493
|
}
|
|
1571
1494
|
function isSwipeIgnoredTarget(target) {
|
|
1572
|
-
return Boolean(
|
|
1495
|
+
return Boolean(closest(target, BASE_UI_SWIPE_IGNORE_SELECTOR));
|
|
1573
1496
|
}
|
|
1574
1497
|
function isDrawerContentTarget(target) {
|
|
1575
|
-
return Boolean(
|
|
1498
|
+
return Boolean(closest(target, DRAWER_CONTENT_SELECTOR));
|
|
1499
|
+
}
|
|
1500
|
+
function getBaseSwipeSize(element, direction) {
|
|
1501
|
+
return 'left' === direction || 'right' === direction ? element.offsetWidth : element.offsetHeight;
|
|
1576
1502
|
}
|
|
1577
1503
|
function getBaseSwipeThreshold(element, direction) {
|
|
1578
|
-
|
|
1579
|
-
return Math.max(0.5 * size, MIN_SWIPE_THRESHOLD);
|
|
1504
|
+
return Math.max(0.5 * getBaseSwipeSize(element, direction), MIN_SWIPE_THRESHOLD);
|
|
1580
1505
|
}
|
|
1581
1506
|
function isRangeInput(target, win) {
|
|
1582
1507
|
return target instanceof win.HTMLInputElement && 'range' === target.type;
|
|
1583
1508
|
}
|
|
1584
1509
|
function isTextSelectionControl(target) {
|
|
1585
|
-
if (!isElement(target)) return false;
|
|
1586
1510
|
return 'INPUT' === target.tagName || 'TEXTAREA' === target.tagName;
|
|
1587
1511
|
}
|
|
1588
1512
|
function hasExpandedSelectionWithinTarget(selection, target) {
|
|
@@ -1592,8 +1516,7 @@ function hasExpandedSelectionWithinTarget(selection, target) {
|
|
|
1592
1516
|
}
|
|
1593
1517
|
function shouldIgnoreSwipeForTextSelection(doc, rootElement) {
|
|
1594
1518
|
const activeEl = activeElement(doc);
|
|
1595
|
-
|
|
1596
|
-
if (activeElementWithinRoot && isTextSelectionControl(activeEl)) {
|
|
1519
|
+
if (activeEl && contains(rootElement, activeEl) && isTextSelectionControl(activeEl)) {
|
|
1597
1520
|
const { selectionStart, selectionEnd } = activeEl;
|
|
1598
1521
|
if (null != selectionStart && null != selectionEnd && selectionStart < selectionEnd) return true;
|
|
1599
1522
|
}
|
|
@@ -1602,9 +1525,7 @@ function shouldIgnoreSwipeForTextSelection(doc, rootElement) {
|
|
|
1602
1525
|
return hasExpandedSelectionWithinTarget(selection, rootElement);
|
|
1603
1526
|
}
|
|
1604
1527
|
function isEventOnRangeInput(event, win) {
|
|
1605
|
-
|
|
1606
|
-
if (composedPath) return composedPath.some((pathTarget)=>isRangeInput(pathTarget, win));
|
|
1607
|
-
return isRangeInput(getTarget(event), win);
|
|
1528
|
+
return event.composedPath().some((pathTarget)=>isRangeInput(pathTarget, win));
|
|
1608
1529
|
}
|
|
1609
1530
|
function isReactTouchEventOnRangeInput(event) {
|
|
1610
1531
|
return isEventOnRangeInput(event.nativeEvent, getWindow(event.currentTarget));
|
|
@@ -1613,19 +1534,29 @@ function updateTouchScrollPosition(touchState, touch) {
|
|
|
1613
1534
|
touchState.lastX = touch.clientX;
|
|
1614
1535
|
touchState.lastY = touch.clientY;
|
|
1615
1536
|
}
|
|
1616
|
-
function
|
|
1537
|
+
function shouldYieldTouchMove(touchState, event, touch, isVerticalScrollAxis) {
|
|
1617
1538
|
if (touchState.preserveNativeCrossAxisScroll) return true;
|
|
1618
|
-
if (true === touchState.allowSwipe || !touchState.
|
|
1539
|
+
if (touchState.drawerAxisAttributed || true === touchState.allowSwipe || !touchState.hasCrossAxisGestureTarget) return false;
|
|
1540
|
+
if (!event.cancelable) {
|
|
1541
|
+
touchState.preserveNativeCrossAxisScroll = true;
|
|
1542
|
+
return true;
|
|
1543
|
+
}
|
|
1619
1544
|
const drawerAxisGestureDelta = isVerticalScrollAxis ? touch.clientY - touchState.startY : touch.clientX - touchState.startX;
|
|
1620
1545
|
const crossAxisGestureDelta = isVerticalScrollAxis ? touch.clientX - touchState.startX : touch.clientY - touchState.startY;
|
|
1621
1546
|
const absDrawerAxisGestureDelta = Math.abs(drawerAxisGestureDelta);
|
|
1622
1547
|
const absCrossAxisGestureDelta = Math.abs(crossAxisGestureDelta);
|
|
1623
|
-
if (absCrossAxisGestureDelta
|
|
1624
|
-
|
|
1548
|
+
if (absCrossAxisGestureDelta >= AXIS_LOCK_SLOP && absCrossAxisGestureDelta > absDrawerAxisGestureDelta + AXIS_LOCK_BIAS) {
|
|
1549
|
+
touchState.preserveNativeCrossAxisScroll = true;
|
|
1550
|
+
return true;
|
|
1551
|
+
}
|
|
1552
|
+
if (absDrawerAxisGestureDelta >= AXIS_LOCK_SLOP) {
|
|
1553
|
+
touchState.drawerAxisAttributed = true;
|
|
1554
|
+
return false;
|
|
1555
|
+
}
|
|
1625
1556
|
return true;
|
|
1626
1557
|
}
|
|
1627
1558
|
function hasScrollableContentOnAxis(scrollTarget, axis) {
|
|
1628
|
-
return
|
|
1559
|
+
return getScrollMetrics(scrollTarget, axis).max > 0;
|
|
1629
1560
|
}
|
|
1630
1561
|
function getScrollMetrics(scrollTarget, axis) {
|
|
1631
1562
|
if ('vertical' === axis) {
|
|
@@ -1642,28 +1573,18 @@ function getScrollMetrics(scrollTarget, axis) {
|
|
|
1642
1573
|
};
|
|
1643
1574
|
}
|
|
1644
1575
|
function isAtSwipeStartEdge(scrollTarget, axis, direction) {
|
|
1645
|
-
const { offset, max } = getScrollMetrics(scrollTarget, axis);
|
|
1646
1576
|
const dismissFromStartEdge = shouldDismissFromStartEdge(direction, axis);
|
|
1647
|
-
|
|
1577
|
+
const { offset, max } = getScrollMetrics(scrollTarget, axis);
|
|
1648
1578
|
return dismissFromStartEdge ? offset <= 0 : offset >= max;
|
|
1649
1579
|
}
|
|
1650
1580
|
function canSwipeFromScrollEdgeOnMove(scrollTarget, axis, direction, delta) {
|
|
1651
|
-
const { offset, max } = getScrollMetrics(scrollTarget, axis);
|
|
1652
1581
|
const dismissFromStartEdge = shouldDismissFromStartEdge(direction, axis);
|
|
1653
|
-
if (null === dismissFromStartEdge) return false;
|
|
1654
1582
|
const movingTowardDismiss = dismissFromStartEdge ? delta > 0 : delta < 0;
|
|
1655
1583
|
if (!movingTowardDismiss) return false;
|
|
1656
|
-
return
|
|
1584
|
+
return isAtSwipeStartEdge(scrollTarget, axis, direction);
|
|
1657
1585
|
}
|
|
1658
1586
|
function shouldDismissFromStartEdge(direction, axis) {
|
|
1659
|
-
|
|
1660
|
-
if ('down' === direction) return true;
|
|
1661
|
-
if ('up' === direction) return false;
|
|
1662
|
-
return null;
|
|
1663
|
-
}
|
|
1664
|
-
if ('right' === direction) return true;
|
|
1665
|
-
if ('left' === direction) return false;
|
|
1666
|
-
return null;
|
|
1587
|
+
return 'vertical' === axis ? 'down' === direction : 'right' === direction;
|
|
1667
1588
|
}
|
|
1668
1589
|
const DrawerTrigger = DialogTrigger_DialogTrigger;
|
|
1669
1590
|
const DrawerClose = DialogClose_DialogClose;
|
|
@@ -1691,6 +1612,7 @@ function DrawerRoot(props) {
|
|
|
1691
1612
|
state: 'snapPoint'
|
|
1692
1613
|
});
|
|
1693
1614
|
const isNestedDrawerOpenRef = __rspack_external_react.useRef(false);
|
|
1615
|
+
const swipeAreaActiveRef = __rspack_external_react.useRef(false);
|
|
1694
1616
|
const setActiveSnapPoint = useStableCallback((nextSnapPoint, eventDetails)=>{
|
|
1695
1617
|
const resolvedEventDetails = eventDetails ?? createChangeEventDetails("none");
|
|
1696
1618
|
onSnapPointChange?.(nextSnapPoint, resolvedEventDetails);
|
|
@@ -1739,6 +1661,7 @@ function DrawerRoot(props) {
|
|
|
1739
1661
|
});
|
|
1740
1662
|
const contextValue = __rspack_external_react.useMemo(()=>({
|
|
1741
1663
|
swipeDirection,
|
|
1664
|
+
swipeAreaActiveRef,
|
|
1742
1665
|
snapToSequentialPoints,
|
|
1743
1666
|
snapPoints,
|
|
1744
1667
|
activeSnapPoint: resolvedActiveSnapPoint,
|
|
@@ -1776,6 +1699,7 @@ function DrawerRoot(props) {
|
|
|
1776
1699
|
setActiveSnapPoint,
|
|
1777
1700
|
snapPoints,
|
|
1778
1701
|
snapToSequentialPoints,
|
|
1702
|
+
swipeAreaActiveRef,
|
|
1779
1703
|
swipeDirection
|
|
1780
1704
|
]);
|
|
1781
1705
|
const resolvedChildren = 'function' == typeof children ? (payload)=>/*#__PURE__*/ jsxs(__rspack_external_react.Fragment, {
|
|
@@ -1789,24 +1713,22 @@ function DrawerRoot(props) {
|
|
|
1789
1713
|
children
|
|
1790
1714
|
]
|
|
1791
1715
|
});
|
|
1716
|
+
const dialog = useRenderDialogRoot('drawer', {
|
|
1717
|
+
open: openProp,
|
|
1718
|
+
defaultOpen,
|
|
1719
|
+
onOpenChange: handleOpenChange,
|
|
1720
|
+
onOpenChangeComplete,
|
|
1721
|
+
disablePointerDismissal,
|
|
1722
|
+
modal,
|
|
1723
|
+
actionsRef,
|
|
1724
|
+
handle,
|
|
1725
|
+
triggerId: triggerIdProp,
|
|
1726
|
+
defaultTriggerId: defaultTriggerIdProp,
|
|
1727
|
+
children: resolvedChildren
|
|
1728
|
+
});
|
|
1792
1729
|
return /*#__PURE__*/ jsx(DrawerRootContext.Provider, {
|
|
1793
1730
|
value: contextValue,
|
|
1794
|
-
children:
|
|
1795
|
-
value: true,
|
|
1796
|
-
children: /*#__PURE__*/ jsx(DialogRoot, {
|
|
1797
|
-
open: openProp,
|
|
1798
|
-
defaultOpen: defaultOpen,
|
|
1799
|
-
onOpenChange: handleOpenChange,
|
|
1800
|
-
onOpenChangeComplete: onOpenChangeComplete,
|
|
1801
|
-
disablePointerDismissal: disablePointerDismissal,
|
|
1802
|
-
modal: modal,
|
|
1803
|
-
actionsRef: actionsRef,
|
|
1804
|
-
handle: handle,
|
|
1805
|
-
triggerId: triggerIdProp,
|
|
1806
|
-
defaultTriggerId: defaultTriggerIdProp,
|
|
1807
|
-
children: resolvedChildren
|
|
1808
|
-
})
|
|
1809
|
-
})
|
|
1731
|
+
children: dialog
|
|
1810
1732
|
});
|
|
1811
1733
|
}
|
|
1812
1734
|
function createNestedSwipeProgressStore() {
|
|
@@ -1831,41 +1753,44 @@ function createNestedSwipeProgressStore() {
|
|
|
1831
1753
|
};
|
|
1832
1754
|
}
|
|
1833
1755
|
function DrawerProviderReporter() {
|
|
1834
|
-
const
|
|
1835
|
-
const
|
|
1836
|
-
const
|
|
1756
|
+
const providerContext = useDrawerProviderContext();
|
|
1757
|
+
const store = useDialogRootContext(false);
|
|
1758
|
+
const setDrawerOpen = providerContext?.setDrawerOpen;
|
|
1759
|
+
const removeDrawer = providerContext?.removeDrawer;
|
|
1837
1760
|
const open = store.useState('open');
|
|
1838
1761
|
const nestedOpenDialogCount = store.useState('nestedOpenDialogCount');
|
|
1839
1762
|
const popupElement = store.useState('popupElement');
|
|
1840
1763
|
const isTopmost = 0 === nestedOpenDialogCount;
|
|
1841
|
-
|
|
1842
|
-
if (!
|
|
1764
|
+
useIsoLayoutEffect(()=>{
|
|
1765
|
+
if (!removeDrawer) return;
|
|
1843
1766
|
return ()=>{
|
|
1844
|
-
|
|
1767
|
+
removeDrawer(store);
|
|
1845
1768
|
};
|
|
1846
1769
|
}, [
|
|
1847
|
-
|
|
1848
|
-
|
|
1770
|
+
removeDrawer,
|
|
1771
|
+
store
|
|
1849
1772
|
]);
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
providerContext?.setDrawerOpen(drawerId, open);
|
|
1773
|
+
useIsoLayoutEffect(()=>{
|
|
1774
|
+
setDrawerOpen?.(store, open);
|
|
1853
1775
|
}, [
|
|
1854
|
-
drawerId,
|
|
1855
1776
|
open,
|
|
1856
|
-
|
|
1777
|
+
setDrawerOpen,
|
|
1778
|
+
store
|
|
1857
1779
|
]);
|
|
1858
1780
|
__rspack_external_react.useEffect(()=>{
|
|
1859
|
-
if (!open || !isTopmost || !
|
|
1781
|
+
if (!open || !isTopmost || !android) return;
|
|
1860
1782
|
const win = getWindow(popupElement);
|
|
1861
1783
|
const CloseWatcherCtor = win.CloseWatcher;
|
|
1862
1784
|
if (!CloseWatcherCtor) return;
|
|
1863
|
-
function
|
|
1785
|
+
function handleCancel(event) {
|
|
1864
1786
|
if (!store.select('open')) return;
|
|
1865
|
-
|
|
1787
|
+
const eventDetails = createChangeEventDetails(reason_parts_closeWatcher, event);
|
|
1788
|
+
if (!event.cancelable) eventDetails.cancel = NOOP;
|
|
1789
|
+
store.setOpen(false, eventDetails);
|
|
1790
|
+
if (eventDetails.isCanceled) event.preventDefault();
|
|
1866
1791
|
}
|
|
1867
1792
|
const closeWatcher = new CloseWatcherCtor();
|
|
1868
|
-
const unsubscribe = addEventListener(closeWatcher, '
|
|
1793
|
+
const unsubscribe = addEventListener(closeWatcher, 'cancel', handleCancel);
|
|
1869
1794
|
return ()=>{
|
|
1870
1795
|
unsubscribe();
|
|
1871
1796
|
closeWatcher.destroy();
|
|
@@ -1881,31 +1806,21 @@ function DrawerProviderReporter() {
|
|
|
1881
1806
|
const DrawerPortal = DialogPortal_DialogPortal;
|
|
1882
1807
|
function DrawerProvider(props) {
|
|
1883
1808
|
const { children } = props;
|
|
1884
|
-
const
|
|
1809
|
+
const openDrawersRef = useRefWithInit(()=>new Set());
|
|
1810
|
+
const [active, setActive] = __rspack_external_react.useState(false);
|
|
1885
1811
|
const [visualStateStore] = __rspack_external_react.useState(createVisualStateStore);
|
|
1886
|
-
const setDrawerOpen = useStableCallback((
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1812
|
+
const setDrawerOpen = useStableCallback((drawer, open)=>{
|
|
1813
|
+
const openDrawers = openDrawersRef.current;
|
|
1814
|
+
if (openDrawers.has(drawer) === open) return;
|
|
1815
|
+
const wasActive = openDrawers.size > 0;
|
|
1816
|
+
if (open) openDrawers.add(drawer);
|
|
1817
|
+
else openDrawers.delete(drawer);
|
|
1818
|
+
const isActive = openDrawers.size > 0;
|
|
1819
|
+
if (isActive !== wasActive) setActive(isActive);
|
|
1894
1820
|
});
|
|
1895
|
-
const removeDrawer = useStableCallback((
|
|
1896
|
-
|
|
1897
|
-
if (!prev.has(drawerId)) return prev;
|
|
1898
|
-
const next = new Map(prev);
|
|
1899
|
-
next.delete(drawerId);
|
|
1900
|
-
return next;
|
|
1901
|
-
});
|
|
1821
|
+
const removeDrawer = useStableCallback((drawer)=>{
|
|
1822
|
+
setDrawerOpen(drawer, false);
|
|
1902
1823
|
});
|
|
1903
|
-
const active = __rspack_external_react.useMemo(()=>{
|
|
1904
|
-
for (const open of openById.values())if (open) return true;
|
|
1905
|
-
return false;
|
|
1906
|
-
}, [
|
|
1907
|
-
openById
|
|
1908
|
-
]);
|
|
1909
1824
|
const contextValue = __rspack_external_react.useMemo(()=>({
|
|
1910
1825
|
setDrawerOpen,
|
|
1911
1826
|
removeDrawer,
|
|
@@ -1952,6 +1867,11 @@ function createVisualStateStore() {
|
|
|
1952
1867
|
}
|
|
1953
1868
|
};
|
|
1954
1869
|
}
|
|
1870
|
+
class DrawerHandle extends DialogHandle {
|
|
1871
|
+
}
|
|
1872
|
+
function createDrawerHandle() {
|
|
1873
|
+
return new DrawerHandle();
|
|
1874
|
+
}
|
|
1955
1875
|
const Backdrop = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx(DrawerBackdrop_DrawerBackdrop, {
|
|
1956
1876
|
ref: ref,
|
|
1957
1877
|
className: className,
|
|
@@ -2026,7 +1946,7 @@ const Drawer = {
|
|
|
2026
1946
|
Description: Description,
|
|
2027
1947
|
Portal: DrawerPortal,
|
|
2028
1948
|
Provider: DrawerProvider,
|
|
2029
|
-
Handle:
|
|
2030
|
-
createHandle:
|
|
1949
|
+
Handle: DrawerHandle,
|
|
1950
|
+
createHandle: createDrawerHandle
|
|
2031
1951
|
};
|
|
2032
1952
|
export { Drawer };
|