@jobber/components 9.4.0 → 9.5.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/Autocomplete/index.cjs +0 -1
- package/dist/Autocomplete/index.mjs +0 -1
- package/dist/Card/index.cjs +7 -7
- package/dist/Card/index.mjs +7 -7
- package/dist/Chip/index.cjs +0 -1
- package/dist/Chip/index.mjs +0 -1
- package/dist/Chips/InternalChipDismissible/hooks/index.cjs +0 -1
- package/dist/Chips/InternalChipDismissible/hooks/index.mjs +0 -1
- package/dist/Chips/InternalChipDismissible/index.cjs +0 -1
- package/dist/Chips/InternalChipDismissible/index.mjs +0 -1
- package/dist/Chips/index.cjs +0 -1
- package/dist/Chips/index.mjs +0 -1
- package/dist/ComboboxChipRemove-cjs.js +181 -184
- package/dist/ComboboxChipRemove-es.js +4 -7
- package/dist/ConfirmationModal/index.cjs +0 -1
- package/dist/ConfirmationModal/index.mjs +0 -1
- package/dist/DataDump/index.cjs +7 -7
- package/dist/DataDump/index.mjs +7 -7
- package/dist/DataList/components/DataListActions/index.cjs +0 -1
- package/dist/DataList/components/DataListActions/index.mjs +0 -1
- package/dist/DataList/components/DataListBulkActions/index.cjs +0 -1
- package/dist/DataList/components/DataListBulkActions/index.mjs +0 -1
- package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +0 -1
- package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +0 -1
- package/dist/DataList/components/DataListFilters/index.cjs +0 -1
- package/dist/DataList/components/DataListFilters/index.mjs +0 -1
- package/dist/DataList/components/DataListHeader/index.cjs +0 -1
- package/dist/DataList/components/DataListHeader/index.mjs +0 -1
- package/dist/DataList/components/DataListItem/index.cjs +0 -1
- package/dist/DataList/components/DataListItem/index.mjs +0 -1
- package/dist/DataList/components/DataListItemActions/index.cjs +0 -1
- package/dist/DataList/components/DataListItemActions/index.mjs +0 -1
- package/dist/DataList/components/DataListItemActionsOverflow/index.cjs +0 -1
- package/dist/DataList/components/DataListItemActionsOverflow/index.mjs +0 -1
- package/dist/DataList/components/DataListItems/index.cjs +0 -1
- package/dist/DataList/components/DataListItems/index.mjs +0 -1
- package/dist/DataList/components/DataListLayout/index.cjs +0 -1
- package/dist/DataList/components/DataListLayout/index.mjs +0 -1
- package/dist/DataList/components/DataListLayoutActions/index.cjs +0 -1
- package/dist/DataList/components/DataListLayoutActions/index.mjs +0 -1
- package/dist/DataList/index.cjs +0 -1
- package/dist/DataList/index.mjs +0 -1
- package/dist/DatePicker/index.cjs +0 -2
- package/dist/DatePicker/index.mjs +0 -2
- package/dist/DatePicker-cjs.js +19 -18
- package/dist/DatePicker-es.js +2 -1
- package/dist/Dialog/index.cjs +11 -6
- package/dist/Dialog/index.mjs +11 -6
- package/dist/DrawerDescription-cjs.js +7 -8
- package/dist/DrawerDescription-es.js +1 -2
- package/dist/DrawerTitle-cjs.js +4 -4
- package/dist/DrawerTitle-es.js +1 -1
- package/dist/FieldDescription-cjs.js +49 -49
- package/dist/FieldDescription-es.js +2 -2
- package/dist/FilterPicker/components/FilterPickerActivator/index.cjs +0 -1
- package/dist/FilterPicker/components/FilterPickerActivator/index.mjs +0 -1
- package/dist/FilterPicker/components/FilterPickerContent/index.cjs +0 -1
- package/dist/FilterPicker/components/FilterPickerContent/index.mjs +0 -1
- package/dist/FilterPicker/components/FilterPickerTrigger/index.cjs +0 -1
- package/dist/FilterPicker/components/FilterPickerTrigger/index.mjs +0 -1
- package/dist/FilterPicker/index.cjs +0 -1
- package/dist/FilterPicker/index.mjs +0 -1
- package/dist/FormatFile/index.cjs +0 -1
- package/dist/FormatFile/index.mjs +0 -1
- package/dist/Gallery/index.cjs +0 -1
- package/dist/Gallery/index.mjs +0 -1
- package/dist/HelperText-cjs.js +3 -2
- package/dist/HelperText-es.js +3 -2
- package/dist/InputDate/index.cjs +0 -2
- package/dist/InputDate/index.mjs +0 -2
- package/dist/InputNumber/InputNumber.d.ts +75 -5
- package/dist/InputNumber/index.cjs +27 -3
- package/dist/InputNumber/index.d.ts +2 -2
- package/dist/InputNumber/index.mjs +27 -3
- package/dist/{primitives/InputNumberExperimental → InputNumber}/types.d.ts +48 -35
- package/dist/InputNumber-cjs.js +267 -4986
- package/dist/InputNumber-es.js +268 -4987
- package/dist/LightBox/index.cjs +0 -1
- package/dist/LightBox/index.mjs +0 -1
- package/dist/Menu/index.cjs +7 -7
- package/dist/Menu/index.mjs +7 -7
- package/dist/Menu-cjs.js +4 -1
- package/dist/Menu-es.js +4 -1
- package/dist/MenuSubmenuTrigger-cjs.js +142 -143
- package/dist/MenuSubmenuTrigger-es.js +5 -6
- package/dist/Modal/index.cjs +0 -1
- package/dist/Modal/index.mjs +0 -1
- package/dist/NumberFieldInput-cjs.js +63 -63
- package/dist/NumberFieldInput-es.js +5 -5
- package/dist/Page/index.cjs +7 -8
- package/dist/Page/index.mjs +7 -8
- package/dist/Popover/index.cjs +0 -1
- package/dist/Popover/index.mjs +0 -1
- package/dist/ScrollAreaViewport-cjs.js +119 -121
- package/dist/ScrollAreaViewport-es.js +3 -5
- package/dist/Select/index.cjs +3 -9
- package/dist/Select/index.mjs +3 -9
- package/dist/SelectGroupLabel-cjs.js +117 -107
- package/dist/SelectGroupLabel-es.js +20 -12
- package/dist/Tooltip/index.cjs +0 -1
- package/dist/Tooltip/index.mjs +0 -1
- package/dist/dialogReturnFocus-cjs.js +4 -1
- package/dist/dialogReturnFocus-es.js +4 -1
- package/dist/docs/InputNumber/InputNumber.md +564 -56
- package/dist/docs/index.md +0 -1
- package/dist/floating-ui.react-cjs.js +34 -35
- package/dist/floating-ui.react-dom-cjs.js +64 -65
- package/dist/floating-ui.react-dom-es.js +1 -2
- package/dist/floating-ui.react-es.js +1 -2
- package/dist/floating-ui.utils-cjs.js +183 -0
- package/dist/floating-ui.utils-es.js +165 -1
- package/dist/index.cjs +10 -15
- package/dist/index.mjs +10 -15
- package/dist/primitives/BottomSheet/index.cjs +2 -5
- package/dist/primitives/BottomSheet/index.mjs +2 -5
- package/dist/primitives/ComboboxPrimitive/index.cjs +3 -7
- package/dist/primitives/ComboboxPrimitive/index.mjs +3 -7
- package/dist/primitives/HelperText/HelperText.d.ts +4 -1
- package/dist/primitives/HelperText/index.cjs +1 -1
- package/dist/primitives/HelperText/index.mjs +1 -1
- package/dist/primitives/SelectPrimitive/index.cjs +3 -9
- package/dist/primitives/SelectPrimitive/index.mjs +3 -9
- package/dist/primitives/index.cjs +2 -16
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.mjs +2 -15
- package/dist/scrollEdges-cjs.js +6 -2
- package/dist/scrollEdges-es.js +5 -2
- package/dist/styles.css +573 -902
- package/dist/unstyledPrimitives/index.cjs +105 -111
- package/dist/unstyledPrimitives/index.mjs +5 -11
- package/dist/useCompositeListItem-cjs.js +516 -90
- package/dist/useCompositeListItem-es.js +407 -6
- package/dist/useLabel-cjs.js +10 -10
- package/dist/useLabel-es.js +3 -3
- package/dist/useRenderElement-es.js +1 -1
- package/dist/useScrollLock-cjs.js +1332 -203
- package/dist/useScrollLock-es.js +1068 -5
- package/dist/utils/meta/meta.json +12 -0
- package/package.json +2 -3
- package/dist/InputNumber/InputNumber.types.d.ts +0 -20
- package/dist/InputNumberExperimental-cjs.js +0 -277
- package/dist/InputNumberExperimental-es.js +0 -275
- package/dist/clamp-cjs.js +0 -7
- package/dist/clamp-es.js +0 -5
- package/dist/clsx-cjs.js +0 -5
- package/dist/clsx-es.js +0 -3
- package/dist/docs/InputNumberExperimental/InputNumberExperimental.md +0 -578
- package/dist/floating-ui.utils.dom-cjs.js +0 -185
- package/dist/floating-ui.utils.dom-es.js +0 -165
- package/dist/isElementDisabled-cjs.js +0 -40
- package/dist/isElementDisabled-es.js +0 -18
- package/dist/primitives/InputNumberExperimental/InputNumberExperimental.d.ts +0 -77
- package/dist/primitives/InputNumberExperimental/index.cjs +0 -30
- package/dist/primitives/InputNumberExperimental/index.d.ts +0 -2
- package/dist/primitives/InputNumberExperimental/index.mjs +0 -24
- package/dist/resolveAriaLabelledBy-cjs.js +0 -200
- package/dist/resolveAriaLabelledBy-es.js +0 -166
- package/dist/useButton-cjs.js +0 -1164
- package/dist/useButton-es.js +0 -1071
- package/dist/useLabelableId-cjs.js +0 -278
- package/dist/useLabelableId-es.js +0 -247
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var useRenderElement = require('./useRenderElement-cjs.js');
|
|
5
5
|
var useScrollLock = require('./useScrollLock-cjs.js');
|
|
6
|
-
var useButton = require('./useButton-cjs.js');
|
|
7
6
|
var scrollEdges = require('./scrollEdges-cjs.js');
|
|
8
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
-
var
|
|
8
|
+
var floatingUi_utils = require('./floating-ui.utils-cjs.js');
|
|
10
9
|
var ReactDOM = require('react-dom');
|
|
11
|
-
var clamp = require('./clamp-cjs.js');
|
|
12
10
|
|
|
13
11
|
function _interopNamespaceDefault(e) {
|
|
14
12
|
var n = Object.create(null);
|
|
@@ -193,7 +191,7 @@ function useDialogRoot(params) {
|
|
|
193
191
|
forceUnmount
|
|
194
192
|
} = useScrollLock.useOpenStateTransitions(open, store);
|
|
195
193
|
const handleImperativeClose = React__namespace.useCallback(() => {
|
|
196
|
-
store.setOpen(false,
|
|
194
|
+
store.setOpen(false, useScrollLock.createChangeEventDetails(useScrollLock.imperativeAction));
|
|
197
195
|
}, [store]);
|
|
198
196
|
React__namespace.useImperativeHandle(actionsRef, () => ({
|
|
199
197
|
unmount: forceUnmount,
|
|
@@ -238,13 +236,13 @@ function DialogInteractions({
|
|
|
238
236
|
if ('touches' in event && event.touches.length !== 1) {
|
|
239
237
|
return false;
|
|
240
238
|
}
|
|
241
|
-
const target =
|
|
239
|
+
const target = useScrollLock.getTarget(event);
|
|
242
240
|
if (isTopmost && !disablePointerDismissal) {
|
|
243
241
|
// Only close if the click occurred on the dialog's owning backdrop.
|
|
244
242
|
// This supports multiple modal dialogs that aren't nested in the React tree:
|
|
245
243
|
// https://github.com/mui/base-ui/issues/1320
|
|
246
244
|
if (modal) {
|
|
247
|
-
return store.context.internalBackdropRef.current || store.context.backdropRef.current ? store.context.internalBackdropRef.current === target || store.context.backdropRef.current === target ||
|
|
245
|
+
return store.context.internalBackdropRef.current || store.context.backdropRef.current ? store.context.internalBackdropRef.current === target || store.context.backdropRef.current === target || useScrollLock.contains(target, popupElement) && !target?.hasAttribute('data-base-ui-portal') : true;
|
|
248
246
|
}
|
|
249
247
|
return true;
|
|
250
248
|
}
|
|
@@ -492,7 +490,7 @@ let DialogViewportDataAttributes = function (DialogViewportDataAttributes) {
|
|
|
492
490
|
|
|
493
491
|
const stateAttributesMapping$2 = {
|
|
494
492
|
...useScrollLock.popupStateMapping,
|
|
495
|
-
...
|
|
493
|
+
...useScrollLock.transitionStatusMapping,
|
|
496
494
|
nested(value) {
|
|
497
495
|
return value ? {
|
|
498
496
|
[DialogViewportDataAttributes.nested]: ''
|
|
@@ -577,7 +575,7 @@ const DialogTrigger = /*#__PURE__*/React__namespace.forwardRef(function DialogTr
|
|
|
577
575
|
if (!store) {
|
|
578
576
|
throw new Error(process.env.NODE_ENV !== "production" ? 'Base UI: <Dialog.Trigger> must be used within <Dialog.Root> or provided with a handle.' : useRenderElement.formatErrorMessage(79));
|
|
579
577
|
}
|
|
580
|
-
const thisTriggerId =
|
|
578
|
+
const thisTriggerId = useScrollLock.useBaseUiId(idProp);
|
|
581
579
|
const floatingContext = store.useState('floatingRootContext');
|
|
582
580
|
const isOpenedByThisTrigger = store.useState('isOpenedByTrigger', thisTriggerId);
|
|
583
581
|
const popupId = store.useState('triggerPopupId', thisTriggerId);
|
|
@@ -591,7 +589,7 @@ const DialogTrigger = /*#__PURE__*/React__namespace.forwardRef(function DialogTr
|
|
|
591
589
|
const {
|
|
592
590
|
getButtonProps,
|
|
593
591
|
buttonRef
|
|
594
|
-
} =
|
|
592
|
+
} = useScrollLock.useButton({
|
|
595
593
|
disabled,
|
|
596
594
|
native: nativeButton
|
|
597
595
|
});
|
|
@@ -671,7 +669,7 @@ let DrawerBackdropCssVars = /*#__PURE__*/function (DrawerBackdropCssVars) {
|
|
|
671
669
|
|
|
672
670
|
const stateAttributesMapping$1 = {
|
|
673
671
|
...useScrollLock.popupStateMapping,
|
|
674
|
-
...
|
|
672
|
+
...useScrollLock.transitionStatusMapping
|
|
675
673
|
};
|
|
676
674
|
|
|
677
675
|
/**
|
|
@@ -826,7 +824,7 @@ function resolveSnapPointValue(snapPoint, viewportHeight, rootFontSize) {
|
|
|
826
824
|
return null;
|
|
827
825
|
}
|
|
828
826
|
if (snapPoint <= 1) {
|
|
829
|
-
return
|
|
827
|
+
return scrollEdges.clamp(snapPoint, 0, 1) * viewportHeight;
|
|
830
828
|
}
|
|
831
829
|
return snapPoint;
|
|
832
830
|
}
|
|
@@ -866,8 +864,8 @@ function useDrawerSnapPoints() {
|
|
|
866
864
|
const viewportElement = store.useState('viewportElement');
|
|
867
865
|
const [viewportHeight, setViewportHeight] = React__namespace.useState(0);
|
|
868
866
|
const [rootFontSize, setRootFontSize] = React__namespace.useState(16);
|
|
869
|
-
const measureViewportHeight =
|
|
870
|
-
const doc =
|
|
867
|
+
const measureViewportHeight = useScrollLock.useStableCallback(() => {
|
|
868
|
+
const doc = useScrollLock.ownerDocument(viewportElement);
|
|
871
869
|
const html = doc.documentElement;
|
|
872
870
|
if (viewportElement) {
|
|
873
871
|
setViewportHeight(viewportElement.offsetHeight);
|
|
@@ -880,7 +878,7 @@ function useDrawerSnapPoints() {
|
|
|
880
878
|
setRootFontSize(fontSize);
|
|
881
879
|
}
|
|
882
880
|
});
|
|
883
|
-
|
|
881
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
884
882
|
measureViewportHeight();
|
|
885
883
|
if (!viewportElement || typeof ResizeObserver !== 'function') {
|
|
886
884
|
return undefined;
|
|
@@ -904,7 +902,7 @@ function useDrawerSnapPoints() {
|
|
|
904
902
|
if (resolvedHeight === null || !Number.isFinite(resolvedHeight)) {
|
|
905
903
|
return null;
|
|
906
904
|
}
|
|
907
|
-
const clampedHeight =
|
|
905
|
+
const clampedHeight = scrollEdges.clamp(resolvedHeight, 0, maxHeight);
|
|
908
906
|
return {
|
|
909
907
|
value,
|
|
910
908
|
height: clampedHeight,
|
|
@@ -944,7 +942,7 @@ function useDrawerSnapPoints() {
|
|
|
944
942
|
if (resolvedHeight === null || !Number.isFinite(resolvedHeight)) {
|
|
945
943
|
return undefined;
|
|
946
944
|
}
|
|
947
|
-
const clampedHeight =
|
|
945
|
+
const clampedHeight = scrollEdges.clamp(resolvedHeight, 0, maxHeight);
|
|
948
946
|
return findClosestSnapPoint(clampedHeight, resolvedSnapPoints) ?? undefined;
|
|
949
947
|
}, [activeSnapPoint, popupHeight, resolvedSnapPoints, rootFontSize, viewportHeight]);
|
|
950
948
|
return {
|
|
@@ -1021,7 +1019,7 @@ function removeCSSVariableInheritance$1() {
|
|
|
1021
1019
|
}
|
|
1022
1020
|
const stateAttributesMapping = {
|
|
1023
1021
|
...useScrollLock.popupStateMapping,
|
|
1024
|
-
...
|
|
1022
|
+
...useScrollLock.transitionStatusMapping,
|
|
1025
1023
|
expanded(value) {
|
|
1026
1024
|
return value ? {
|
|
1027
1025
|
[DrawerPopupDataAttributes.expanded]: ''
|
|
@@ -1111,12 +1109,12 @@ const DrawerPopup = /*#__PURE__*/React__namespace.forwardRef(function DrawerPopu
|
|
|
1111
1109
|
if (swipe) {
|
|
1112
1110
|
return;
|
|
1113
1111
|
}
|
|
1114
|
-
const ownerStackMessage =
|
|
1112
|
+
const ownerStackMessage = useScrollLock.SafeReact.captureOwnerStack?.() || '';
|
|
1115
1113
|
const message = '<Drawer.Popup> expected to be rendered within <Drawer.Viewport>. Omitting the ' + 'viewport disables drawer swipe handling and touch scroll locking. Wrap ' + '<Drawer.Popup> in <Drawer.Viewport>.';
|
|
1116
|
-
|
|
1114
|
+
useScrollLock.error(`${message}${ownerStackMessage}`);
|
|
1117
1115
|
}, [swipe]);
|
|
1118
1116
|
}
|
|
1119
|
-
const measureHeight =
|
|
1117
|
+
const measureHeight = useScrollLock.useStableCallback(() => {
|
|
1120
1118
|
const popupElement = popupRef.current;
|
|
1121
1119
|
if (!popupElement) {
|
|
1122
1120
|
return;
|
|
@@ -1142,7 +1140,7 @@ const DrawerPopup = /*#__PURE__*/React__namespace.forwardRef(function DrawerPopu
|
|
|
1142
1140
|
setPopupHeight(nextHeight);
|
|
1143
1141
|
onPopupHeightChange(nextHeight);
|
|
1144
1142
|
});
|
|
1145
|
-
|
|
1143
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
1146
1144
|
if (!mounted) {
|
|
1147
1145
|
popupHeightRef.current = 0;
|
|
1148
1146
|
setPopupHeight(0);
|
|
@@ -1164,7 +1162,7 @@ const DrawerPopup = /*#__PURE__*/React__namespace.forwardRef(function DrawerPopu
|
|
|
1164
1162
|
resizeObserver.disconnect();
|
|
1165
1163
|
};
|
|
1166
1164
|
}, [measureHeight, mounted, nestedDrawerOpen, onPopupHeightChange, popupRef]);
|
|
1167
|
-
|
|
1165
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
1168
1166
|
const syncNestedSwipeProgress = () => {
|
|
1169
1167
|
const popupElement = popupRef.current;
|
|
1170
1168
|
if (!popupElement) {
|
|
@@ -1206,7 +1204,7 @@ const DrawerPopup = /*#__PURE__*/React__namespace.forwardRef(function DrawerPopu
|
|
|
1206
1204
|
notifyParentHasNestedDrawer(false);
|
|
1207
1205
|
};
|
|
1208
1206
|
}, [notifyParentHasNestedDrawer, open, transitionStatus]);
|
|
1209
|
-
|
|
1207
|
+
useScrollLock.useOpenChangeComplete({
|
|
1210
1208
|
open,
|
|
1211
1209
|
ref: popupRef,
|
|
1212
1210
|
onComplete() {
|
|
@@ -1343,15 +1341,15 @@ function DrawerRoot(props) {
|
|
|
1343
1341
|
const [nestedSwipeProgressStore] = React__namespace.useState(createNestedSwipeProgressStore);
|
|
1344
1342
|
const resolvedDefaultSnapPoint = defaultSnapPoint !== undefined ? defaultSnapPoint : snapPoints?.[0] ?? null;
|
|
1345
1343
|
const isSnapPointControlled = snapPointProp !== undefined;
|
|
1346
|
-
const [activeSnapPoint, setActiveSnapPointUnwrapped] =
|
|
1344
|
+
const [activeSnapPoint, setActiveSnapPointUnwrapped] = useScrollLock.useControlled({
|
|
1347
1345
|
controlled: snapPointProp,
|
|
1348
1346
|
default: resolvedDefaultSnapPoint,
|
|
1349
1347
|
name: 'Drawer',
|
|
1350
1348
|
state: 'snapPoint'
|
|
1351
1349
|
});
|
|
1352
1350
|
const isNestedDrawerOpenRef = React__namespace.useRef(false);
|
|
1353
|
-
const setActiveSnapPoint =
|
|
1354
|
-
const resolvedEventDetails = eventDetails ??
|
|
1351
|
+
const setActiveSnapPoint = useScrollLock.useStableCallback((nextSnapPoint, eventDetails) => {
|
|
1352
|
+
const resolvedEventDetails = eventDetails ?? useScrollLock.createChangeEventDetails(useScrollLock.none);
|
|
1355
1353
|
onSnapPointChange?.(nextSnapPoint, resolvedEventDetails);
|
|
1356
1354
|
if (resolvedEventDetails.isCanceled) {
|
|
1357
1355
|
return;
|
|
@@ -1370,13 +1368,13 @@ function DrawerRoot(props) {
|
|
|
1370
1368
|
}
|
|
1371
1369
|
return activeSnapPoint;
|
|
1372
1370
|
}, [activeSnapPoint, isSnapPointControlled, resolvedDefaultSnapPoint, snapPoints]);
|
|
1373
|
-
const onPopupHeightChange =
|
|
1371
|
+
const onPopupHeightChange = useScrollLock.useStableCallback(height => {
|
|
1374
1372
|
setPopupHeight(height);
|
|
1375
1373
|
if (!isNestedDrawerOpenRef.current && height > 0) {
|
|
1376
1374
|
setFrontmostHeight(height);
|
|
1377
1375
|
}
|
|
1378
1376
|
});
|
|
1379
|
-
const onNestedFrontmostHeightChange =
|
|
1377
|
+
const onNestedFrontmostHeightChange = useScrollLock.useStableCallback(height => {
|
|
1380
1378
|
if (height > 0) {
|
|
1381
1379
|
isNestedDrawerOpenRef.current = true;
|
|
1382
1380
|
setFrontmostHeight(height);
|
|
@@ -1387,24 +1385,24 @@ function DrawerRoot(props) {
|
|
|
1387
1385
|
setFrontmostHeight(popupHeight);
|
|
1388
1386
|
}
|
|
1389
1387
|
});
|
|
1390
|
-
const onNestedDrawerPresenceChange =
|
|
1388
|
+
const onNestedDrawerPresenceChange = useScrollLock.useStableCallback(present => {
|
|
1391
1389
|
setHasNestedDrawer(present);
|
|
1392
1390
|
});
|
|
1393
|
-
const onNestedSwipeProgressChange =
|
|
1391
|
+
const onNestedSwipeProgressChange = useScrollLock.useStableCallback(progress => {
|
|
1394
1392
|
nestedSwipeProgressStore.set(progress);
|
|
1395
1393
|
notifyParentSwipeProgressChange?.(progress);
|
|
1396
1394
|
});
|
|
1397
|
-
const onNestedSwipingChange =
|
|
1395
|
+
const onNestedSwipingChange = useScrollLock.useStableCallback(swiping => {
|
|
1398
1396
|
setNestedSwiping(swiping);
|
|
1399
1397
|
notifyParentSwipingChange?.(swiping);
|
|
1400
1398
|
});
|
|
1401
|
-
const handleOpenChange =
|
|
1399
|
+
const handleOpenChange = useScrollLock.useStableCallback((nextOpen, eventDetails) => {
|
|
1402
1400
|
onOpenChange?.(nextOpen, eventDetails);
|
|
1403
1401
|
if (eventDetails.isCanceled) {
|
|
1404
1402
|
return;
|
|
1405
1403
|
}
|
|
1406
1404
|
if (!nextOpen && snapPoints && snapPoints.length > 0) {
|
|
1407
|
-
setActiveSnapPoint(resolvedDefaultSnapPoint,
|
|
1405
|
+
setActiveSnapPoint(resolvedDefaultSnapPoint, useScrollLock.createChangeEventDetails(eventDetails.reason, eventDetails.event, eventDetails.trigger));
|
|
1408
1406
|
}
|
|
1409
1407
|
});
|
|
1410
1408
|
const contextValue = React__namespace.useMemo(() => ({
|
|
@@ -1477,7 +1475,7 @@ function createNestedSwipeProgressStore() {
|
|
|
1477
1475
|
};
|
|
1478
1476
|
}
|
|
1479
1477
|
function DrawerProviderReporter() {
|
|
1480
|
-
const drawerId =
|
|
1478
|
+
const drawerId = useScrollLock.useId();
|
|
1481
1479
|
const providerContext = useDrawerProviderContext();
|
|
1482
1480
|
const {
|
|
1483
1481
|
store
|
|
@@ -1503,10 +1501,10 @@ function DrawerProviderReporter() {
|
|
|
1503
1501
|
React__namespace.useEffect(() => {
|
|
1504
1502
|
// CloseWatcher enables the Android back gesture (Chromium-only).
|
|
1505
1503
|
// Keep this Android-only for now to avoid interfering with Escape/nesting semantics on desktop due to `useDismiss`.
|
|
1506
|
-
if (!open || !isTopmost || !
|
|
1504
|
+
if (!open || !isTopmost || !useScrollLock.android) {
|
|
1507
1505
|
return undefined;
|
|
1508
1506
|
}
|
|
1509
|
-
const win =
|
|
1507
|
+
const win = floatingUi_utils.getWindow(popupElement);
|
|
1510
1508
|
const CloseWatcherCtor = win.CloseWatcher;
|
|
1511
1509
|
if (!CloseWatcherCtor) {
|
|
1512
1510
|
return undefined;
|
|
@@ -1515,10 +1513,10 @@ function DrawerProviderReporter() {
|
|
|
1515
1513
|
if (!store.select('open')) {
|
|
1516
1514
|
return;
|
|
1517
1515
|
}
|
|
1518
|
-
store.setOpen(false,
|
|
1516
|
+
store.setOpen(false, useScrollLock.createChangeEventDetails(useScrollLock.closeWatcher, event));
|
|
1519
1517
|
}
|
|
1520
1518
|
const closeWatcher = new CloseWatcherCtor();
|
|
1521
|
-
const unsubscribe =
|
|
1519
|
+
const unsubscribe = useScrollLock.addEventListener(closeWatcher, 'close', handleCloseWatcher);
|
|
1522
1520
|
return () => {
|
|
1523
1521
|
unsubscribe();
|
|
1524
1522
|
closeWatcher.destroy();
|
|
@@ -1531,7 +1529,7 @@ function isScrollable(element, axis,
|
|
|
1531
1529
|
// When true, a container that overflows only once extra space is added (e.g. drawer
|
|
1532
1530
|
// keyboard scroll slack) still counts, as long as it has layout size on the axis.
|
|
1533
1531
|
allowOverflowIntent = false) {
|
|
1534
|
-
const style =
|
|
1532
|
+
const style = floatingUi_utils.getComputedStyle(element);
|
|
1535
1533
|
if (axis === 'vertical') {
|
|
1536
1534
|
const overflowY = style.overflowY;
|
|
1537
1535
|
if (overflowY !== 'auto' && overflowY !== 'scroll') {
|
|
@@ -1549,25 +1547,25 @@ function hasScrollableAncestor(target, root, axes) {
|
|
|
1549
1547
|
// `getParentNode` crosses shadow boundaries (and slots), so a target inside a shadow root
|
|
1550
1548
|
// still walks up to scrollable ancestors in the light DOM.
|
|
1551
1549
|
let node = target;
|
|
1552
|
-
while (
|
|
1550
|
+
while (floatingUi_utils.isHTMLElement(node) && node !== root && !floatingUi_utils.isLastTraversableNode(node)) {
|
|
1553
1551
|
for (const axis of axes) {
|
|
1554
1552
|
if (isScrollable(node, axis)) {
|
|
1555
1553
|
return true;
|
|
1556
1554
|
}
|
|
1557
1555
|
}
|
|
1558
|
-
node =
|
|
1556
|
+
node = floatingUi_utils.getParentNode(node);
|
|
1559
1557
|
}
|
|
1560
1558
|
return false;
|
|
1561
1559
|
}
|
|
1562
1560
|
function findScrollableTouchTarget(target, root, axis = 'vertical', allowOverflowIntent = false) {
|
|
1563
1561
|
// `getParentNode` crosses shadow boundaries (and slots), so a target inside a shadow root
|
|
1564
1562
|
// still reaches a scrollable ancestor in the light DOM.
|
|
1565
|
-
let node =
|
|
1566
|
-
while (
|
|
1563
|
+
let node = floatingUi_utils.isHTMLElement(target) ? target : null;
|
|
1564
|
+
while (floatingUi_utils.isHTMLElement(node) && node !== root && !floatingUi_utils.isLastTraversableNode(node)) {
|
|
1567
1565
|
if (isScrollable(node, axis, allowOverflowIntent)) {
|
|
1568
1566
|
return node;
|
|
1569
1567
|
}
|
|
1570
|
-
node =
|
|
1568
|
+
node = floatingUi_utils.getParentNode(node);
|
|
1571
1569
|
}
|
|
1572
1570
|
return isScrollable(root, axis, allowOverflowIntent) ? root : null;
|
|
1573
1571
|
}
|
|
@@ -1598,7 +1596,7 @@ function getDisplacement(direction, deltaX, deltaY) {
|
|
|
1598
1596
|
}
|
|
1599
1597
|
}
|
|
1600
1598
|
function getElementTransform(element) {
|
|
1601
|
-
const computedStyle =
|
|
1599
|
+
const computedStyle = floatingUi_utils.getWindow(element).getComputedStyle(element);
|
|
1602
1600
|
const transform = computedStyle.transform;
|
|
1603
1601
|
let translateX = 0;
|
|
1604
1602
|
let translateY = 0;
|
|
@@ -1729,7 +1727,7 @@ function useSwipeDismiss(options) {
|
|
|
1729
1727
|
const lastProgressDetailsRef = React__namespace.useRef(null);
|
|
1730
1728
|
const isSwipingRef = React__namespace.useRef(false);
|
|
1731
1729
|
const dragStyleSnapshotRef = React__namespace.useRef(null);
|
|
1732
|
-
const setSwiping =
|
|
1730
|
+
const setSwiping = useScrollLock.useStableCallback(nextSwiping => {
|
|
1733
1731
|
if (isSwipingRef.current === nextSwiping) {
|
|
1734
1732
|
return;
|
|
1735
1733
|
}
|
|
@@ -1755,8 +1753,8 @@ function useSwipeDismiss(options) {
|
|
|
1755
1753
|
});
|
|
1756
1754
|
swipeThresholdRef.current = Math.max(0, value);
|
|
1757
1755
|
}
|
|
1758
|
-
const updateSwipeProgress =
|
|
1759
|
-
const nextProgress = Number.isFinite(progress) ?
|
|
1756
|
+
const updateSwipeProgress = useScrollLock.useStableCallback((progress, details) => {
|
|
1757
|
+
const nextProgress = Number.isFinite(progress) ? scrollEdges.clamp(progress, 0, 1) : 0;
|
|
1760
1758
|
const progressChanged = nextProgress !== swipeProgressRef.current;
|
|
1761
1759
|
let detailsChanged = false;
|
|
1762
1760
|
if (details) {
|
|
@@ -1774,7 +1772,7 @@ function useSwipeDismiss(options) {
|
|
|
1774
1772
|
}
|
|
1775
1773
|
onProgress?.(nextProgress, details);
|
|
1776
1774
|
});
|
|
1777
|
-
const syncDragStyles =
|
|
1775
|
+
const syncDragStyles = useScrollLock.useStableCallback(swiping => {
|
|
1778
1776
|
const element = elementRef.current;
|
|
1779
1777
|
if (!trackDrag || !element) {
|
|
1780
1778
|
if (!swiping) {
|
|
@@ -1892,9 +1890,9 @@ function useSwipeDismiss(options) {
|
|
|
1892
1890
|
return event.pointerType === 'touch';
|
|
1893
1891
|
}
|
|
1894
1892
|
function getTargetAtPoint(position, nativeEvent) {
|
|
1895
|
-
const doc =
|
|
1893
|
+
const doc = useScrollLock.ownerDocument(elementRef.current);
|
|
1896
1894
|
const elementAtPoint = getElementAtPoint(doc, position.x, position.y);
|
|
1897
|
-
const target = elementAtPoint ??
|
|
1895
|
+
const target = elementAtPoint ?? useScrollLock.getTarget(nativeEvent);
|
|
1898
1896
|
return target;
|
|
1899
1897
|
}
|
|
1900
1898
|
function findGestureScrollableTouchTarget(target, root) {
|
|
@@ -1910,7 +1908,7 @@ function useSwipeDismiss(options) {
|
|
|
1910
1908
|
swipeFromScrollableRef.current = false;
|
|
1911
1909
|
const touchLike = isTouchLikeEvent(event);
|
|
1912
1910
|
const target = getTargetAtPoint(position, event.nativeEvent);
|
|
1913
|
-
const doc =
|
|
1911
|
+
const doc = useScrollLock.ownerDocument(elementRef.current);
|
|
1914
1912
|
const body = doc.body;
|
|
1915
1913
|
const scrollableTarget = touchLike && body ? findGestureScrollableTouchTarget(target, body) : null;
|
|
1916
1914
|
const ignoreScrollableTarget = startOptions?.ignoreScrollableTarget ?? false;
|
|
@@ -2044,7 +2042,7 @@ function useSwipeDismiss(options) {
|
|
|
2044
2042
|
}
|
|
2045
2043
|
return null;
|
|
2046
2044
|
}
|
|
2047
|
-
const handleStart =
|
|
2045
|
+
const handleStart = useScrollLock.useStableCallback(event => {
|
|
2048
2046
|
if (!enabled) {
|
|
2049
2047
|
return;
|
|
2050
2048
|
}
|
|
@@ -2077,7 +2075,7 @@ function useSwipeDismiss(options) {
|
|
|
2077
2075
|
if (!enabled || !isSwipingRef.current) {
|
|
2078
2076
|
return;
|
|
2079
2077
|
}
|
|
2080
|
-
const target =
|
|
2078
|
+
const target = useScrollLock.getTarget(event.nativeEvent);
|
|
2081
2079
|
if (isTouchLikeEvent(event) && !swipeFromScrollableRef.current) {
|
|
2082
2080
|
const boundaryElement = event.currentTarget;
|
|
2083
2081
|
if (findGestureScrollableTouchTarget(target, boundaryElement)) {
|
|
@@ -2230,7 +2228,7 @@ function useSwipeDismiss(options) {
|
|
|
2230
2228
|
direction: swipeDirectionDetails
|
|
2231
2229
|
});
|
|
2232
2230
|
}
|
|
2233
|
-
const handleEnd =
|
|
2231
|
+
const handleEnd = useScrollLock.useStableCallback(event => {
|
|
2234
2232
|
if (!enabled) {
|
|
2235
2233
|
return;
|
|
2236
2234
|
}
|
|
@@ -2364,7 +2362,7 @@ function useSwipeDismiss(options) {
|
|
|
2364
2362
|
updateSwipeProgress(0, progressDetails);
|
|
2365
2363
|
}
|
|
2366
2364
|
});
|
|
2367
|
-
const handleMove =
|
|
2365
|
+
const handleMove = useScrollLock.useStableCallback(event => {
|
|
2368
2366
|
const currentPos = getPrimaryPointerPosition(event);
|
|
2369
2367
|
if (!currentPos) {
|
|
2370
2368
|
return;
|
|
@@ -2415,10 +2413,10 @@ function useSwipeDismiss(options) {
|
|
|
2415
2413
|
const element = elementRef.current;
|
|
2416
2414
|
if (pendingStartPos && element) {
|
|
2417
2415
|
const target = getTargetAtPoint(currentPos, event.nativeEvent);
|
|
2418
|
-
const doc =
|
|
2416
|
+
const doc = useScrollLock.ownerDocument(element);
|
|
2419
2417
|
const body = doc.body;
|
|
2420
2418
|
const scrollTarget = body ? findGestureScrollableTouchTarget(target, body) : null;
|
|
2421
|
-
if (scrollTarget && (
|
|
2419
|
+
if (scrollTarget && (useScrollLock.contains(element, scrollTarget) || useScrollLock.contains(scrollTarget, element))) {
|
|
2422
2420
|
const deltaX = currentPos.x - pendingStartPos.x;
|
|
2423
2421
|
const deltaY = currentPos.y - pendingStartPos.y;
|
|
2424
2422
|
const canSwipeFromEdge = canSwipeFromScrollEdgeOnPendingMove(scrollTarget, deltaX, deltaY);
|
|
@@ -2474,7 +2472,7 @@ function useSwipeDismiss(options) {
|
|
|
2474
2472
|
|
|
2475
2473
|
// Feeds a native touchmove into the swipe pipeline. Used by consumers that claim the gesture
|
|
2476
2474
|
// in a capture-phase listener and stop it from reaching React's delegated touch handlers.
|
|
2477
|
-
const moveNative =
|
|
2475
|
+
const moveNative = useScrollLock.useStableCallback((nativeEvent, currentTarget) => {
|
|
2478
2476
|
handleMove({
|
|
2479
2477
|
touches: nativeEvent.touches,
|
|
2480
2478
|
currentTarget,
|
|
@@ -2612,7 +2610,7 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
2612
2610
|
const [swipeRelease, setSwipeRelease] = React__namespace.useState(null);
|
|
2613
2611
|
const pendingSwipeCloseSnapPointRef = React__namespace.useRef(undefined);
|
|
2614
2612
|
const resetSwipeRef = React__namespace.useRef(null);
|
|
2615
|
-
const controlledDismissFrame =
|
|
2613
|
+
const controlledDismissFrame = useScrollLock.useAnimationFrame();
|
|
2616
2614
|
const swipingRef = React__namespace.useRef(false);
|
|
2617
2615
|
const nestedSwipeActiveRef = React__namespace.useRef(false);
|
|
2618
2616
|
const lastPointerTypeRef = React__namespace.useRef('');
|
|
@@ -2654,7 +2652,7 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
2654
2652
|
if (!snapPointRange || activeSnapPointOffset === null) {
|
|
2655
2653
|
return null;
|
|
2656
2654
|
}
|
|
2657
|
-
return
|
|
2655
|
+
return scrollEdges.clamp((activeSnapPointOffset - snapPointRange.minOffset) / snapPointRange.range, 0, 1);
|
|
2658
2656
|
}, [activeSnapPointOffset, snapPointRange]);
|
|
2659
2657
|
const swipeDirections = React__namespace.useMemo(() => {
|
|
2660
2658
|
if (snapPoints && snapPoints.length > 0 && (swipeDirection === 'down' || swipeDirection === 'up')) {
|
|
@@ -2662,22 +2660,22 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
2662
2660
|
}
|
|
2663
2661
|
return [swipeDirection];
|
|
2664
2662
|
}, [snapPoints, swipeDirection]);
|
|
2665
|
-
const setSwipeDismissed =
|
|
2663
|
+
const setSwipeDismissed = useScrollLock.useStableCallback(dismissed => {
|
|
2666
2664
|
setSwipeDismissedElements(popupRef.current, backdropRef.current, dismissed);
|
|
2667
2665
|
});
|
|
2668
|
-
const clearSwipeRelease =
|
|
2666
|
+
const clearSwipeRelease = useScrollLock.useStableCallback(() => {
|
|
2669
2667
|
setSwipeDismissed(false);
|
|
2670
|
-
popupRef.current?.removeAttribute(
|
|
2668
|
+
popupRef.current?.removeAttribute(useScrollLock.TransitionStatusDataAttributes.endingStyle);
|
|
2671
2669
|
setSwipeRelease(null);
|
|
2672
2670
|
});
|
|
2673
|
-
const finishNestedSwipe =
|
|
2671
|
+
const finishNestedSwipe = useScrollLock.useStableCallback(() => {
|
|
2674
2672
|
if (!nestedSwipeActiveRef.current) {
|
|
2675
2673
|
return;
|
|
2676
2674
|
}
|
|
2677
2675
|
nestedSwipeActiveRef.current = false;
|
|
2678
2676
|
notifyParentSwipingChange?.(false);
|
|
2679
2677
|
});
|
|
2680
|
-
const applySwipeProgress =
|
|
2678
|
+
const applySwipeProgress = useScrollLock.useStableCallback(({
|
|
2681
2679
|
resolvedProgress,
|
|
2682
2680
|
shouldTrackProgress,
|
|
2683
2681
|
notifyParent
|
|
@@ -2752,13 +2750,13 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
2752
2750
|
if (!Number.isFinite(directionalVelocity) || directionalVelocity <= MIN_SWIPE_RELEASE_VELOCITY) {
|
|
2753
2751
|
return null;
|
|
2754
2752
|
}
|
|
2755
|
-
const clampedVelocity =
|
|
2756
|
-
const durationMs =
|
|
2753
|
+
const clampedVelocity = scrollEdges.clamp(directionalVelocity, MIN_SWIPE_RELEASE_VELOCITY, MAX_SWIPE_RELEASE_VELOCITY);
|
|
2754
|
+
const durationMs = scrollEdges.clamp(remainingDistance / clampedVelocity, MIN_SWIPE_RELEASE_DURATION_MS, MAX_SWIPE_RELEASE_DURATION_MS);
|
|
2757
2755
|
if (!Number.isFinite(durationMs)) {
|
|
2758
2756
|
return null;
|
|
2759
2757
|
}
|
|
2760
2758
|
const normalizedDuration = (durationMs - MIN_SWIPE_RELEASE_DURATION_MS) / (MAX_SWIPE_RELEASE_DURATION_MS - MIN_SWIPE_RELEASE_DURATION_MS);
|
|
2761
|
-
const durationScalar =
|
|
2759
|
+
const durationScalar = scrollEdges.clamp(MIN_SWIPE_RELEASE_SCALAR + normalizedDuration * (MAX_SWIPE_RELEASE_SCALAR - MIN_SWIPE_RELEASE_SCALAR), MIN_SWIPE_RELEASE_SCALAR, MAX_SWIPE_RELEASE_SCALAR);
|
|
2762
2760
|
if (!Number.isFinite(durationScalar) || durationScalar <= 0) {
|
|
2763
2761
|
return null;
|
|
2764
2762
|
}
|
|
@@ -2794,14 +2792,14 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
2794
2792
|
if (!popupElement) {
|
|
2795
2793
|
return;
|
|
2796
2794
|
}
|
|
2797
|
-
const doc =
|
|
2795
|
+
const doc = useScrollLock.ownerDocument(popupElement);
|
|
2798
2796
|
const selection = doc.getSelection?.();
|
|
2799
2797
|
if (!selection || selection.isCollapsed) {
|
|
2800
2798
|
return;
|
|
2801
2799
|
}
|
|
2802
|
-
const anchorElement =
|
|
2803
|
-
const focusElement =
|
|
2804
|
-
if (!
|
|
2800
|
+
const anchorElement = floatingUi_utils.isElement(selection.anchorNode) ? selection.anchorNode : selection.anchorNode?.parentElement;
|
|
2801
|
+
const focusElement = floatingUi_utils.isElement(selection.focusNode) ? selection.focusNode : selection.focusNode?.parentElement;
|
|
2802
|
+
if (!useScrollLock.contains(popupElement, anchorElement) && !useScrollLock.contains(popupElement, focusElement)) {
|
|
2805
2803
|
return;
|
|
2806
2804
|
}
|
|
2807
2805
|
selection.removeAllRanges();
|
|
@@ -2826,7 +2824,7 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
2826
2824
|
}
|
|
2827
2825
|
const doc = popupElement.ownerDocument;
|
|
2828
2826
|
const elementAtPoint = getElementAtPoint(doc, position.x, position.y);
|
|
2829
|
-
if (!elementAtPoint || !
|
|
2827
|
+
if (!elementAtPoint || !useScrollLock.contains(popupElement, elementAtPoint)) {
|
|
2830
2828
|
return false;
|
|
2831
2829
|
}
|
|
2832
2830
|
const nativeEvent = details.nativeEvent;
|
|
@@ -2857,15 +2855,15 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
2857
2855
|
if (snapPointRange && popupHeight > 0) {
|
|
2858
2856
|
if (details && Number.isFinite(details.deltaY)) {
|
|
2859
2857
|
const baseOffset = activeSnapPointOffset ?? snapPointRange.minOffset;
|
|
2860
|
-
const nextOffset =
|
|
2861
|
-
resolvedProgress =
|
|
2858
|
+
const nextOffset = scrollEdges.clamp(baseOffset + details.deltaY, 0, popupHeight);
|
|
2859
|
+
resolvedProgress = scrollEdges.clamp((nextOffset - snapPointRange.minOffset) / snapPointRange.range, 0, 1);
|
|
2862
2860
|
} else if (snapPointProgress !== null) {
|
|
2863
2861
|
resolvedProgress = snapPointProgress;
|
|
2864
2862
|
} else if (currentDirection === 'down' || currentDirection === 'up') {
|
|
2865
2863
|
const displacement = progress * popupHeight;
|
|
2866
2864
|
const baseOffset = activeSnapPointOffset ?? snapPointRange.minOffset;
|
|
2867
2865
|
const nextOffset = currentDirection === 'down' ? baseOffset + displacement : baseOffset - displacement;
|
|
2868
|
-
resolvedProgress =
|
|
2866
|
+
resolvedProgress = scrollEdges.clamp((nextOffset - snapPointRange.minOffset) / snapPointRange.range, 0, 1);
|
|
2869
2867
|
}
|
|
2870
2868
|
}
|
|
2871
2869
|
applySwipeProgress({
|
|
@@ -2902,7 +2900,7 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
2902
2900
|
finishNestedSwipe();
|
|
2903
2901
|
setSwipeDismissed(true);
|
|
2904
2902
|
popupElement.style.removeProperty('transition');
|
|
2905
|
-
popupElement.setAttribute(
|
|
2903
|
+
popupElement.setAttribute(useScrollLock.TransitionStatusDataAttributes.endingStyle, '');
|
|
2906
2904
|
ReactDOM__namespace.flushSync(() => {
|
|
2907
2905
|
setSwipeRelease(resolveSwipeRelease({
|
|
2908
2906
|
direction: resolvedDirection,
|
|
@@ -2970,10 +2968,10 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
2970
2968
|
}
|
|
2971
2969
|
}
|
|
2972
2970
|
const currentOffset = activeSnapPointOffset ?? 0;
|
|
2973
|
-
const dragTargetOffset =
|
|
2974
|
-
const velocityOffset = Number.isFinite(resolvedDirectionalVelocity) && Math.abs(resolvedDirectionalVelocity) >= SNAP_VELOCITY_THRESHOLD ?
|
|
2975
|
-
const targetOffset = snapToSequentialPoints ? dragTargetOffset :
|
|
2976
|
-
const snapPointEventDetails =
|
|
2971
|
+
const dragTargetOffset = scrollEdges.clamp(currentOffset + dragDelta, 0, popupHeight);
|
|
2972
|
+
const velocityOffset = Number.isFinite(resolvedDirectionalVelocity) && Math.abs(resolvedDirectionalVelocity) >= SNAP_VELOCITY_THRESHOLD ? scrollEdges.clamp(resolvedDirectionalVelocity, -MAX_SNAP_VELOCITY, MAX_SNAP_VELOCITY) * SNAP_VELOCITY_MULTIPLIER : 0;
|
|
2973
|
+
const targetOffset = snapToSequentialPoints ? dragTargetOffset : scrollEdges.clamp(dragTargetOffset + velocityOffset, 0, popupHeight);
|
|
2974
|
+
const snapPointEventDetails = useScrollLock.createChangeEventDetails(useScrollLock.swipe, event);
|
|
2977
2975
|
const closeFromSnapPoints = () => {
|
|
2978
2976
|
pendingSwipeCloseSnapPointRef.current = activeSnapPoint;
|
|
2979
2977
|
setActiveSnapPoint?.(null, snapPointEventDetails);
|
|
@@ -3008,7 +3006,7 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
3008
3006
|
const shouldAdvance = dragDirection !== 0 && velocityDirection !== 0 && velocityDirection === dragDirection && Math.abs(resolvedDirectionalVelocity) >= SNAP_VELOCITY_THRESHOLD;
|
|
3009
3007
|
let effectiveTargetOffset = targetOffset;
|
|
3010
3008
|
if (shouldAdvance) {
|
|
3011
|
-
const adjacentIndex =
|
|
3009
|
+
const adjacentIndex = scrollEdges.clamp(currentIndex + dragDirection, 0, orderedSnapPoints.length - 1);
|
|
3012
3010
|
if (adjacentIndex !== currentIndex) {
|
|
3013
3011
|
const adjacentPoint = orderedSnapPoints[adjacentIndex];
|
|
3014
3012
|
const shouldForceAdjacent = dragDirection > 0 ? targetOffset < adjacentPoint.offset : targetOffset > adjacentPoint.offset;
|
|
@@ -3061,12 +3059,12 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
3061
3059
|
backdropElement.style.setProperty(DrawerBackdropCssVars.swipeProgress, '0');
|
|
3062
3060
|
backdropElement.style.removeProperty(DrawerPopupCssVars.height);
|
|
3063
3061
|
}
|
|
3064
|
-
const dismissEventDetails =
|
|
3062
|
+
const dismissEventDetails = useScrollLock.createChangeEventDetails(useScrollLock.swipe, event);
|
|
3065
3063
|
store.setOpen(false, dismissEventDetails);
|
|
3066
3064
|
if (dismissEventDetails.isCanceled) {
|
|
3067
3065
|
const pendingSnapPoint = pendingSwipeCloseSnapPointRef.current;
|
|
3068
3066
|
if (pendingSnapPoint !== undefined) {
|
|
3069
|
-
setActiveSnapPoint?.(pendingSnapPoint,
|
|
3067
|
+
setActiveSnapPoint?.(pendingSnapPoint, useScrollLock.createChangeEventDetails(useScrollLock.swipe, event));
|
|
3070
3068
|
}
|
|
3071
3069
|
pendingSwipeCloseSnapPointRef.current = undefined;
|
|
3072
3070
|
resetSwipeRef.current?.();
|
|
@@ -3088,7 +3086,7 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
3088
3086
|
// Parent rejected: revert animation and restore snap point.
|
|
3089
3087
|
const pendingSnapPoint = pendingSwipeCloseSnapPointRef.current;
|
|
3090
3088
|
if (pendingSnapPoint !== undefined) {
|
|
3091
|
-
setActiveSnapPoint?.(pendingSnapPoint,
|
|
3089
|
+
setActiveSnapPoint?.(pendingSnapPoint, useScrollLock.createChangeEventDetails(useScrollLock.swipe, savedEvent));
|
|
3092
3090
|
}
|
|
3093
3091
|
pendingSwipeCloseSnapPointRef.current = undefined;
|
|
3094
3092
|
clearSwipeRelease();
|
|
@@ -3117,8 +3115,8 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
3117
3115
|
return undefined;
|
|
3118
3116
|
}
|
|
3119
3117
|
const resolvedRootElement = rootElement;
|
|
3120
|
-
const doc =
|
|
3121
|
-
const win =
|
|
3118
|
+
const doc = useScrollLock.ownerDocument(resolvedRootElement);
|
|
3119
|
+
const win = floatingUi_utils.getWindow(doc);
|
|
3122
3120
|
function handleNativeTouchMove(event) {
|
|
3123
3121
|
// The virtual keyboard provider observes the move to tell a tap apart from a drag.
|
|
3124
3122
|
// It must run even when the swipe gesture below claims the event with
|
|
@@ -3201,7 +3199,7 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
3201
3199
|
}
|
|
3202
3200
|
updateTouchScrollPosition(touchState, touch);
|
|
3203
3201
|
}
|
|
3204
|
-
return
|
|
3202
|
+
return useScrollLock.addEventListener(doc, 'touchmove', handleNativeTouchMove, {
|
|
3205
3203
|
passive: false,
|
|
3206
3204
|
capture: true
|
|
3207
3205
|
});
|
|
@@ -3277,7 +3275,7 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
3277
3275
|
if (!open || !mounted || nestedDrawerOpen) {
|
|
3278
3276
|
return;
|
|
3279
3277
|
}
|
|
3280
|
-
const doc =
|
|
3278
|
+
const doc = useScrollLock.ownerDocument(event.currentTarget);
|
|
3281
3279
|
const elementAtPoint = getElementAtPoint(doc, event.clientX, event.clientY);
|
|
3282
3280
|
if (isSwipeIgnoredTarget(elementAtPoint) || isDrawerContentTarget(elementAtPoint)) {
|
|
3283
3281
|
return;
|
|
@@ -3333,12 +3331,12 @@ const DrawerViewport = /*#__PURE__*/React__namespace.forwardRef(function DrawerV
|
|
|
3333
3331
|
touchScrollStateRef.current = null;
|
|
3334
3332
|
return;
|
|
3335
3333
|
}
|
|
3336
|
-
const doc =
|
|
3334
|
+
const doc = useScrollLock.ownerDocument(event.currentTarget);
|
|
3337
3335
|
const elementAtPoint = getElementAtPoint(doc, touch.clientX, touch.clientY);
|
|
3338
3336
|
const rootElement = viewportElement ?? popupElementState;
|
|
3339
|
-
const eventTarget =
|
|
3340
|
-
const target =
|
|
3341
|
-
if (rootElement && target && !
|
|
3337
|
+
const eventTarget = useScrollLock.getTarget(event.nativeEvent);
|
|
3338
|
+
const target = floatingUi_utils.isElement(eventTarget) ? eventTarget : null;
|
|
3339
|
+
if (rootElement && target && !useScrollLock.contains(rootElement, target)) {
|
|
3342
3340
|
ignoreTouchSwipeRef.current = true;
|
|
3343
3341
|
touchScrollStateRef.current = null;
|
|
3344
3342
|
return;
|
|
@@ -3426,19 +3424,19 @@ function isRangeInput(target, win) {
|
|
|
3426
3424
|
return target instanceof win.HTMLInputElement && target.type === 'range';
|
|
3427
3425
|
}
|
|
3428
3426
|
function isTextSelectionControl(target) {
|
|
3429
|
-
if (!
|
|
3427
|
+
if (!floatingUi_utils.isElement(target)) {
|
|
3430
3428
|
return false;
|
|
3431
3429
|
}
|
|
3432
3430
|
return target.tagName === 'INPUT' || target.tagName === 'TEXTAREA';
|
|
3433
3431
|
}
|
|
3434
3432
|
function hasExpandedSelectionWithinTarget(selection, target) {
|
|
3435
|
-
const anchorElement =
|
|
3436
|
-
const focusElement =
|
|
3437
|
-
return selection.containsNode(target, true) ||
|
|
3433
|
+
const anchorElement = floatingUi_utils.isElement(selection.anchorNode) ? selection.anchorNode : selection.anchorNode?.parentElement;
|
|
3434
|
+
const focusElement = floatingUi_utils.isElement(selection.focusNode) ? selection.focusNode : selection.focusNode?.parentElement;
|
|
3435
|
+
return selection.containsNode(target, true) || useScrollLock.contains(target, anchorElement) || useScrollLock.contains(target, focusElement);
|
|
3438
3436
|
}
|
|
3439
3437
|
function shouldIgnoreSwipeForTextSelection(doc, rootElement) {
|
|
3440
|
-
const activeEl =
|
|
3441
|
-
const activeElementWithinRoot = Boolean(activeEl &&
|
|
3438
|
+
const activeEl = useScrollLock.activeElement(doc);
|
|
3439
|
+
const activeElementWithinRoot = Boolean(activeEl && useScrollLock.contains(rootElement, activeEl));
|
|
3442
3440
|
if (activeElementWithinRoot && isTextSelectionControl(activeEl)) {
|
|
3443
3441
|
const {
|
|
3444
3442
|
selectionStart,
|
|
@@ -3459,10 +3457,10 @@ function isEventOnRangeInput(event, win) {
|
|
|
3459
3457
|
if (composedPath) {
|
|
3460
3458
|
return composedPath.some(pathTarget => isRangeInput(pathTarget, win));
|
|
3461
3459
|
}
|
|
3462
|
-
return isRangeInput(
|
|
3460
|
+
return isRangeInput(useScrollLock.getTarget(event), win);
|
|
3463
3461
|
}
|
|
3464
3462
|
function isReactTouchEventOnRangeInput(event) {
|
|
3465
|
-
return isEventOnRangeInput(event.nativeEvent,
|
|
3463
|
+
return isEventOnRangeInput(event.nativeEvent, floatingUi_utils.getWindow(event.currentTarget));
|
|
3466
3464
|
}
|
|
3467
3465
|
function updateTouchScrollPosition(touchState, touch) {
|
|
3468
3466
|
touchState.lastX = touch.clientX;
|
|
@@ -3723,9 +3721,9 @@ const ScrollAreaRoot = /*#__PURE__*/React__namespace.forwardRef(function ScrollA
|
|
|
3723
3721
|
yStart,
|
|
3724
3722
|
yEnd
|
|
3725
3723
|
} = normalizeOverflowEdgeThreshold(overflowEdgeThresholdProp);
|
|
3726
|
-
const rootId =
|
|
3727
|
-
const scrollYTimeout =
|
|
3728
|
-
const scrollXTimeout =
|
|
3724
|
+
const rootId = useScrollLock.useBaseUiId();
|
|
3725
|
+
const scrollYTimeout = useScrollLock.useTimeout();
|
|
3726
|
+
const scrollXTimeout = useScrollLock.useTimeout();
|
|
3729
3727
|
const {
|
|
3730
3728
|
nonce,
|
|
3731
3729
|
disableStyleElements
|
|
@@ -3753,7 +3751,7 @@ const ScrollAreaRoot = /*#__PURE__*/React__namespace.forwardRef(function ScrollA
|
|
|
3753
3751
|
const startScrollLeftRef = React__namespace.useRef(0);
|
|
3754
3752
|
const currentOrientationRef = React__namespace.useRef('vertical');
|
|
3755
3753
|
const scrollPositionRef = React__namespace.useRef(DEFAULT_COORDS);
|
|
3756
|
-
const handleScroll =
|
|
3754
|
+
const handleScroll = useScrollLock.useStableCallback(scrollPosition => {
|
|
3757
3755
|
const offsetX = scrollPosition.x - scrollPositionRef.current.x;
|
|
3758
3756
|
const offsetY = scrollPosition.y - scrollPositionRef.current.y;
|
|
3759
3757
|
scrollPositionRef.current = scrollPosition;
|
|
@@ -3770,7 +3768,7 @@ const ScrollAreaRoot = /*#__PURE__*/React__namespace.forwardRef(function ScrollA
|
|
|
3770
3768
|
});
|
|
3771
3769
|
}
|
|
3772
3770
|
});
|
|
3773
|
-
const handlePointerDown =
|
|
3771
|
+
const handlePointerDown = useScrollLock.useStableCallback(event => {
|
|
3774
3772
|
if (event.button !== 0) {
|
|
3775
3773
|
return;
|
|
3776
3774
|
}
|
|
@@ -3789,7 +3787,7 @@ const ScrollAreaRoot = /*#__PURE__*/React__namespace.forwardRef(function ScrollA
|
|
|
3789
3787
|
thumbXRef.current.setPointerCapture(event.pointerId);
|
|
3790
3788
|
}
|
|
3791
3789
|
});
|
|
3792
|
-
const handlePointerMove =
|
|
3790
|
+
const handlePointerMove = useScrollLock.useStableCallback(event => {
|
|
3793
3791
|
if (!thumbDraggingRef.current) {
|
|
3794
3792
|
return;
|
|
3795
3793
|
}
|
|
@@ -3828,7 +3826,7 @@ const ScrollAreaRoot = /*#__PURE__*/React__namespace.forwardRef(function ScrollA
|
|
|
3828
3826
|
}
|
|
3829
3827
|
}
|
|
3830
3828
|
});
|
|
3831
|
-
const handlePointerUp =
|
|
3829
|
+
const handlePointerUp = useScrollLock.useStableCallback(event => {
|
|
3832
3830
|
thumbDraggingRef.current = false;
|
|
3833
3831
|
|
|
3834
3832
|
// `pointercancel` releases capture implicitly, so guard against releasing a
|
|
@@ -3846,7 +3844,7 @@ const ScrollAreaRoot = /*#__PURE__*/React__namespace.forwardRef(function ScrollA
|
|
|
3846
3844
|
function handlePointerEnterOrMove(event) {
|
|
3847
3845
|
handleTouchModalityChange(event);
|
|
3848
3846
|
if (event.pointerType !== 'touch') {
|
|
3849
|
-
const isTargetRootChild =
|
|
3847
|
+
const isTargetRootChild = useScrollLock.contains(rootRef.current, event.target);
|
|
3850
3848
|
setHovering(isTargetRootChild);
|
|
3851
3849
|
}
|
|
3852
3850
|
}
|
|
@@ -4048,9 +4046,9 @@ const ScrollAreaViewport = /*#__PURE__*/React__namespace.forwardRef(function Scr
|
|
|
4048
4046
|
const direction = useScrollLock.useDirection();
|
|
4049
4047
|
const programmaticScrollRef = React__namespace.useRef(true);
|
|
4050
4048
|
const lastMeasuredViewportMetricsRef = React__namespace.useRef([NaN, NaN, NaN, NaN]);
|
|
4051
|
-
const scrollEndTimeout =
|
|
4052
|
-
const waitForAnimationsTimeout =
|
|
4053
|
-
const computeThumbPosition =
|
|
4049
|
+
const scrollEndTimeout = useScrollLock.useTimeout();
|
|
4050
|
+
const waitForAnimationsTimeout = useScrollLock.useTimeout();
|
|
4051
|
+
const computeThumbPosition = useScrollLock.useStableCallback(() => {
|
|
4054
4052
|
const viewportEl = viewportRef.current;
|
|
4055
4053
|
const scrollbarYEl = scrollbarYRef.current;
|
|
4056
4054
|
const scrollbarXEl = scrollbarXRef.current;
|
|
@@ -4090,14 +4088,14 @@ const ScrollAreaViewport = /*#__PURE__*/React__namespace.forwardRef(function Scr
|
|
|
4090
4088
|
if (!scrollbarXHidden) {
|
|
4091
4089
|
let rawScrollLeftFromStart = 0;
|
|
4092
4090
|
if (direction === 'rtl') {
|
|
4093
|
-
rawScrollLeftFromStart =
|
|
4091
|
+
rawScrollLeftFromStart = scrollEdges.clamp(-scrollLeft, 0, maxScrollLeft);
|
|
4094
4092
|
} else {
|
|
4095
|
-
rawScrollLeftFromStart =
|
|
4093
|
+
rawScrollLeftFromStart = scrollEdges.clamp(scrollLeft, 0, maxScrollLeft);
|
|
4096
4094
|
}
|
|
4097
4095
|
scrollLeftFromStart = scrollEdges.normalizeScrollOffset(rawScrollLeftFromStart, maxScrollLeft);
|
|
4098
4096
|
scrollLeftFromEnd = maxScrollLeft - scrollLeftFromStart;
|
|
4099
4097
|
}
|
|
4100
|
-
const rawScrollTopFromStart = !scrollbarYHidden ?
|
|
4098
|
+
const rawScrollTopFromStart = !scrollbarYHidden ? scrollEdges.clamp(scrollTop, 0, maxScrollTop) : 0;
|
|
4101
4099
|
const scrollTopFromStart = !scrollbarYHidden ? scrollEdges.normalizeScrollOffset(rawScrollTopFromStart, maxScrollTop) : 0;
|
|
4102
4100
|
const scrollTopFromEnd = !scrollbarYHidden ? maxScrollTop - scrollTopFromStart : 0;
|
|
4103
4101
|
const nextWidth = scrollbarXHidden ? 0 : viewportWidth;
|
|
@@ -4154,7 +4152,7 @@ const ScrollAreaViewport = /*#__PURE__*/React__namespace.forwardRef(function Scr
|
|
|
4154
4152
|
|
|
4155
4153
|
// In Safari, don't allow it to go negative or too far as `scrollLeft` considers the rubber
|
|
4156
4154
|
// band effect.
|
|
4157
|
-
const thumbOffsetX = direction === 'rtl' ?
|
|
4155
|
+
const thumbOffsetX = direction === 'rtl' ? scrollEdges.clamp(scrollRatioX * maxThumbOffsetX, -maxThumbOffsetX, 0) : scrollEdges.clamp(scrollRatioX * maxThumbOffsetX, 0, maxThumbOffsetX);
|
|
4158
4156
|
thumbXEl.style.transform = `translate3d(${thumbOffsetX}px,0,0)`;
|
|
4159
4157
|
}
|
|
4160
4158
|
const overflowMetricsPx = [[ScrollAreaViewportCssVars.scrollAreaOverflowXStart, scrollLeftFromStart], [ScrollAreaViewportCssVars.scrollAreaOverflowXEnd, scrollLeftFromEnd], [ScrollAreaViewportCssVars.scrollAreaOverflowYStart, scrollTopFromStart], [ScrollAreaViewportCssVars.scrollAreaOverflowYEnd, scrollTopFromEnd]];
|
|
@@ -4188,25 +4186,25 @@ const ScrollAreaViewport = /*#__PURE__*/React__namespace.forwardRef(function Scr
|
|
|
4188
4186
|
return nextOverflowEdges;
|
|
4189
4187
|
});
|
|
4190
4188
|
});
|
|
4191
|
-
|
|
4189
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
4192
4190
|
if (!viewportRef.current) {
|
|
4193
4191
|
return;
|
|
4194
4192
|
}
|
|
4195
4193
|
removeCSSVariableInheritance();
|
|
4196
4194
|
}, [viewportRef]);
|
|
4197
|
-
|
|
4195
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
4198
4196
|
// Wait for scrollbar and thumb refs after hidden-state toggles, refresh math on direction
|
|
4199
4197
|
// flips, and re-evaluate overflow edges when the threshold changes.
|
|
4200
4198
|
queueMicrotask(computeThumbPosition);
|
|
4201
4199
|
}, [computeThumbPosition, hiddenState, direction, overflowEdgeThreshold.xStart, overflowEdgeThreshold.xEnd, overflowEdgeThreshold.yStart, overflowEdgeThreshold.yEnd]);
|
|
4202
|
-
|
|
4200
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
4203
4201
|
// `onMouseEnter` doesn't fire upon load, so we need to check if the viewport is already
|
|
4204
4202
|
// being hovered.
|
|
4205
4203
|
if (viewportRef.current?.matches(':hover')) {
|
|
4206
4204
|
setHovering(true);
|
|
4207
4205
|
}
|
|
4208
4206
|
}, [viewportRef, setHovering]);
|
|
4209
|
-
|
|
4207
|
+
useScrollLock.useIsoLayoutEffect(() => {
|
|
4210
4208
|
const viewport = viewportRef.current;
|
|
4211
4209
|
if (typeof ResizeObserver === 'undefined' || !viewport) {
|
|
4212
4210
|
return undefined;
|