@octanejs/base-ui 0.1.31 → 0.1.32
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/cjs/accordion.cjs +497 -0
- package/dist/cjs/alert-dialog.cjs +65 -0
- package/dist/cjs/avatar.cjs +234 -0
- package/dist/cjs/button.cjs +54 -0
- package/dist/cjs/checkbox-group.cjs +165 -0
- package/dist/cjs/checkbox.cjs +475 -0
- package/dist/cjs/collapsible.cjs +700 -0
- package/dist/cjs/context-menu.cjs +257 -0
- package/dist/cjs/csp-provider.cjs +40 -0
- package/dist/cjs/dialog.cjs +741 -0
- package/dist/cjs/direction-provider.cjs +35 -0
- package/dist/cjs/field.cjs +559 -0
- package/dist/cjs/fieldset.cjs +101 -0
- package/dist/cjs/form.cjs +177 -0
- package/dist/cjs/index.cjs +133 -0
- package/dist/cjs/input.cjs +32 -0
- package/dist/cjs/internal.cjs +51 -0
- package/dist/cjs/menu.cjs +2420 -0
- package/dist/cjs/menubar.cjs +132 -0
- package/dist/cjs/merge-props.cjs +34 -0
- package/dist/cjs/meter.cjs +169 -0
- package/dist/cjs/number-field.cjs +812 -0
- package/dist/cjs/popover.cjs +966 -0
- package/dist/cjs/preview-card.cjs +632 -0
- package/dist/cjs/progress.cjs +206 -0
- package/dist/cjs/radio-group.cjs +264 -0
- package/dist/cjs/radio.cjs +327 -0
- package/dist/cjs/separator.cjs +44 -0
- package/dist/cjs/slider.cjs +1384 -0
- package/dist/cjs/switch.cjs +306 -0
- package/dist/cjs/tabs.cjs +727 -0
- package/dist/cjs/toast.cjs +1766 -0
- package/dist/cjs/toggle-group.cjs +118 -0
- package/dist/cjs/toggle.cjs +121 -0
- package/dist/cjs/tooltip.cjs +835 -0
- package/dist/cjs/unstable-use-media-query.cjs +79 -0
- package/dist/cjs/use-render.cjs +40 -0
- package/dist/cjs/utils/CSPContext.cjs +38 -0
- package/dist/cjs/utils/CheckboxGroupContext.cjs +40 -0
- package/dist/cjs/utils/CompositeRootContext.cjs +40 -0
- package/dist/cjs/utils/ContextMenuRootContext.cjs +42 -0
- package/dist/cjs/utils/DirectionContext.cjs +34 -0
- package/dist/cjs/utils/FloatingPortalLite.cjs +47 -0
- package/dist/cjs/utils/InternalBackdrop.cjs +49 -0
- package/dist/cjs/utils/MenubarContext.cjs +40 -0
- package/dist/cjs/utils/RadioGroupContext.cjs +34 -0
- package/dist/cjs/utils/RequestQueue.cjs +111 -0
- package/dist/cjs/utils/TimeoutManager.cjs +50 -0
- package/dist/cjs/utils/ToggleGroupContext.cjs +40 -0
- package/dist/cjs/utils/adaptiveOriginMiddleware.cjs +94 -0
- package/dist/cjs/utils/addEventListener.cjs +33 -0
- package/dist/cjs/utils/areArraysEqual.cjs +30 -0
- package/dist/cjs/utils/clamp.cjs +30 -0
- package/dist/cjs/utils/closePart.cjs +70 -0
- package/dist/cjs/utils/collapsibleOpenStateMapping.cjs +42 -0
- package/dist/cjs/utils/composeRefs.cjs +68 -0
- package/dist/cjs/utils/composite/CompositeItem.cjs +59 -0
- package/dist/cjs/utils/composite/CompositeList.cjs +177 -0
- package/dist/cjs/utils/composite/CompositeListContext.cjs +43 -0
- package/dist/cjs/utils/composite/CompositeRoot.cjs +118 -0
- package/dist/cjs/utils/composite/grid-utils.cjs +343 -0
- package/dist/cjs/utils/composite/gridNavigation.cjs +92 -0
- package/dist/cjs/utils/composite/keys.cjs +174 -0
- package/dist/cjs/utils/composite/list-utils.cjs +90 -0
- package/dist/cjs/utils/composite/useCompositeItem.cjs +63 -0
- package/dist/cjs/utils/composite/useCompositeListItem.cjs +104 -0
- package/dist/cjs/utils/composite/useCompositeRoot.cjs +263 -0
- package/dist/cjs/utils/constants.cjs +56 -0
- package/dist/cjs/utils/contains.cjs +46 -0
- package/dist/cjs/utils/createChangeEventDetails.cjs +92 -0
- package/dist/cjs/utils/dom.cjs +35 -0
- package/dist/cjs/utils/empty.cjs +34 -0
- package/dist/cjs/utils/field/FieldItemContext.cjs +34 -0
- package/dist/cjs/utils/field/FieldRootContext.cjs +80 -0
- package/dist/cjs/utils/field/FormContext.cjs +41 -0
- package/dist/cjs/utils/field/LabelableContext.cjs +43 -0
- package/dist/cjs/utils/field/LabelableProvider.cjs +115 -0
- package/dist/cjs/utils/field/constants.cjs +68 -0
- package/dist/cjs/utils/field/getCombinedFieldValidityData.cjs +36 -0
- package/dist/cjs/utils/field/useAriaLabelledBy.cjs +87 -0
- package/dist/cjs/utils/field/useFieldControlRegistration.cjs +165 -0
- package/dist/cjs/utils/field/useFieldValidation.cjs +285 -0
- package/dist/cjs/utils/field/useLabel.cjs +99 -0
- package/dist/cjs/utils/field/useLabelableId.cjs +105 -0
- package/dist/cjs/utils/field/useRegisterFieldControl.cjs +60 -0
- package/dist/cjs/utils/findRootOwnerId.cjs +37 -0
- package/dist/cjs/utils/floating/FloatingDelayGroup.cjs +219 -0
- package/dist/cjs/utils/floating/FloatingFocusManager.cjs +685 -0
- package/dist/cjs/utils/floating/FloatingPortal.cjs +230 -0
- package/dist/cjs/utils/floating/FloatingRootStore.cjs +87 -0
- package/dist/cjs/utils/floating/FloatingTree.cjs +86 -0
- package/dist/cjs/utils/floating/FloatingTreeStore.cjs +41 -0
- package/dist/cjs/utils/floating/FocusGuard.cjs +54 -0
- package/dist/cjs/utils/floating/composite.cjs +42 -0
- package/dist/cjs/utils/floating/constants.cjs +34 -0
- package/dist/cjs/utils/floating/createAttribute.cjs +30 -0
- package/dist/cjs/utils/floating/createEventEmitter.cjs +44 -0
- package/dist/cjs/utils/floating/element.cjs +103 -0
- package/dist/cjs/utils/floating/enqueueFocus.cjs +51 -0
- package/dist/cjs/utils/floating/event.cjs +65 -0
- package/dist/cjs/utils/floating/getEmptyRootContext.cjs +42 -0
- package/dist/cjs/utils/floating/gridNavigation.cjs +45 -0
- package/dist/cjs/utils/floating/markOthers.cjs +181 -0
- package/dist/cjs/utils/floating/nodes.cjs +48 -0
- package/dist/cjs/utils/floating/safePolygon.cjs +301 -0
- package/dist/cjs/utils/floating/tabbable.cjs +242 -0
- package/dist/cjs/utils/floating/types.cjs +16 -0
- package/dist/cjs/utils/floating/useClick.cjs +153 -0
- package/dist/cjs/utils/floating/useClientPoint.cjs +225 -0
- package/dist/cjs/utils/floating/useDismiss.cjs +506 -0
- package/dist/cjs/utils/floating/useFloating.cjs +186 -0
- package/dist/cjs/utils/floating/useFloatingRootContext.cjs +75 -0
- package/dist/cjs/utils/floating/useFocus.cjs +184 -0
- package/dist/cjs/utils/floating/useHoverFloatingInteraction.cjs +231 -0
- package/dist/cjs/utils/floating/useHoverInteractionSharedState.cjs +113 -0
- package/dist/cjs/utils/floating/useHoverReferenceInteraction.cjs +380 -0
- package/dist/cjs/utils/floating/useHoverShared.cjs +65 -0
- package/dist/cjs/utils/floating/useListNavigation.cjs +665 -0
- package/dist/cjs/utils/floating/useSyncedFloatingRootContext.cjs +91 -0
- package/dist/cjs/utils/floating/useTypeahead.cjs +187 -0
- package/dist/cjs/utils/formatNumber.cjs +60 -0
- package/dist/cjs/utils/generateId.cjs +32 -0
- package/dist/cjs/utils/getCssDimensions.cjs +42 -0
- package/dist/cjs/utils/getDefaultFormSubmitter.cjs +42 -0
- package/dist/cjs/utils/getDisabledMountTransitionStyles.cjs +32 -0
- package/dist/cjs/utils/getElementRef.cjs +35 -0
- package/dist/cjs/utils/getPseudoElementBounds.cjs +56 -0
- package/dist/cjs/utils/getStateAttributesProps.cjs +46 -0
- package/dist/cjs/utils/hideMiddleware.cjs +42 -0
- package/dist/cjs/utils/inertValue.cjs +30 -0
- package/dist/cjs/utils/matchesFocusVisible.cjs +38 -0
- package/dist/cjs/utils/mergeCleanups.cjs +37 -0
- package/dist/cjs/utils/mergeObjects.cjs +39 -0
- package/dist/cjs/utils/mergeProps.cjs +182 -0
- package/dist/cjs/utils/noop.cjs +29 -0
- package/dist/cjs/utils/number/constants.cjs +34 -0
- package/dist/cjs/utils/number/parse.cjs +258 -0
- package/dist/cjs/utils/number/types.cjs +16 -0
- package/dist/cjs/utils/number/validate.cjs +104 -0
- package/dist/cjs/utils/owner.cjs +35 -0
- package/dist/cjs/utils/platform.cjs +83 -0
- package/dist/cjs/utils/popupStateMapping.cjs +74 -0
- package/dist/cjs/utils/popups/index.cjs +39 -0
- package/dist/cjs/utils/popups/inlineRect.cjs +218 -0
- package/dist/cjs/utils/popups/popupStoreUtils.cjs +379 -0
- package/dist/cjs/utils/popups/popupTriggerMap.cjs +76 -0
- package/dist/cjs/utils/popups/store.cjs +118 -0
- package/dist/cjs/utils/popups/useTriggerFocusGuards.cjs +72 -0
- package/dist/cjs/utils/resolveAriaLabelledBy.cjs +35 -0
- package/dist/cjs/utils/resolveClassName.cjs +30 -0
- package/dist/cjs/utils/resolveRef.cjs +33 -0
- package/dist/cjs/utils/resolveStyle.cjs +30 -0
- package/dist/cjs/utils/serializeValue.cjs +40 -0
- package/dist/cjs/utils/slider/asc.cjs +30 -0
- package/dist/cjs/utils/slider/getMidpoint.cjs +34 -0
- package/dist/cjs/utils/slider/getPushedThumbValues.cjs +73 -0
- package/dist/cjs/utils/slider/getSliderValue.cjs +42 -0
- package/dist/cjs/utils/slider/replaceArrayItemAtIndex.cjs +33 -0
- package/dist/cjs/utils/slider/resolveThumbCollision.cjs +155 -0
- package/dist/cjs/utils/slider/roundValueToStep.cjs +45 -0
- package/dist/cjs/utils/slider/validateMinimumDistance.cjs +40 -0
- package/dist/cjs/utils/slider/valueArrayToPercentages.cjs +36 -0
- package/dist/cjs/utils/store/ReactStore.cjs +135 -0
- package/dist/cjs/utils/store/Store.cjs +83 -0
- package/dist/cjs/utils/store/createSelector.cjs +74 -0
- package/dist/cjs/utils/store/useStore.cjs +51 -0
- package/dist/cjs/utils/stringifyLocale.cjs +36 -0
- package/dist/cjs/utils/useAnchorPositioning.cjs +421 -0
- package/dist/cjs/utils/useAnchoredPopupScrollLock.cjs +59 -0
- package/dist/cjs/utils/useAnimationFrame.cjs +93 -0
- package/dist/cjs/utils/useAnimationsFinished.cjs +98 -0
- package/dist/cjs/utils/useBaseUiId.cjs +36 -0
- package/dist/cjs/utils/useButton.cjs +177 -0
- package/dist/cjs/utils/useCheckboxGroupParent.cjs +114 -0
- package/dist/cjs/utils/useControlled.cjs +47 -0
- package/dist/cjs/utils/useEnhancedClickHandler.cjs +60 -0
- package/dist/cjs/utils/useFocusableWhenDisabled.cjs +77 -0
- package/dist/cjs/utils/useForcedRerendering.cjs +35 -0
- package/dist/cjs/utils/useIsHydrating.cjs +44 -0
- package/dist/cjs/utils/useMixedToggleClickHandler.cjs +66 -0
- package/dist/cjs/utils/useOnFirstRender.cjs +35 -0
- package/dist/cjs/utils/useOnMount.cjs +36 -0
- package/dist/cjs/utils/useOpenChangeComplete.cjs +57 -0
- package/dist/cjs/utils/useOpenInteractionType.cjs +69 -0
- package/dist/cjs/utils/usePopupAutoResize.cjs +191 -0
- package/dist/cjs/utils/usePopupViewport.cjs +283 -0
- package/dist/cjs/utils/usePositioner.cjs +53 -0
- package/dist/cjs/utils/usePressAndHold.cjs +51 -0
- package/dist/cjs/utils/usePreviousValue.cjs +47 -0
- package/dist/cjs/utils/useRefWithInit.cjs +41 -0
- package/dist/cjs/utils/useRegisteredLabelId.cjs +48 -0
- package/dist/cjs/utils/useRenderElement.cjs +106 -0
- package/dist/cjs/utils/useScrollLock.cjs +232 -0
- package/dist/cjs/utils/useStableCallback.cjs +41 -0
- package/dist/cjs/utils/useTimeout.cjs +66 -0
- package/dist/cjs/utils/useTransitionStatus.cjs +116 -0
- package/dist/cjs/utils/useValueAsRef.cjs +43 -0
- package/dist/cjs/utils/useValueChanged.cjs +55 -0
- package/dist/cjs/utils/valueToPercent.cjs +30 -0
- package/dist/cjs/utils/visuallyHidden.cjs +49 -0
- package/package.json +20 -8
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var usePositioner_exports = {};
|
|
20
|
+
__export(usePositioner_exports, {
|
|
21
|
+
usePositioner: () => usePositioner
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(usePositioner_exports);
|
|
24
|
+
var import_internal = require("../internal.cjs");
|
|
25
|
+
var import_popupStateMapping = require("./popupStateMapping.cjs");
|
|
26
|
+
var import_useRenderElement = require("./useRenderElement.cjs");
|
|
27
|
+
var import_getDisabledMountTransitionStyles = require("./getDisabledMountTransitionStyles.cjs");
|
|
28
|
+
function usePositioner(componentProps, state, { styles, transitionStatus, props, refs, hidden, inert = false }, slotArg) {
|
|
29
|
+
const slot = slotArg ?? (0, import_internal.S)("usePositioner");
|
|
30
|
+
const style = { ...styles };
|
|
31
|
+
if (inert) {
|
|
32
|
+
style.pointerEvents = "none";
|
|
33
|
+
}
|
|
34
|
+
return (0, import_useRenderElement.useRenderElement)(
|
|
35
|
+
"div",
|
|
36
|
+
componentProps,
|
|
37
|
+
{
|
|
38
|
+
state,
|
|
39
|
+
ref: refs,
|
|
40
|
+
props: [
|
|
41
|
+
{ role: "presentation", hidden, style },
|
|
42
|
+
(0, import_getDisabledMountTransitionStyles.getDisabledMountTransitionStyles)(transitionStatus),
|
|
43
|
+
props
|
|
44
|
+
],
|
|
45
|
+
stateAttributesMapping: import_popupStateMapping.popupStateMapping
|
|
46
|
+
},
|
|
47
|
+
(0, import_internal.subSlot)(slot, "re")
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
usePositioner
|
|
53
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var usePressAndHold_exports = {};
|
|
20
|
+
__export(usePressAndHold_exports, {
|
|
21
|
+
isTouchLikePointerType: () => isTouchLikePointerType,
|
|
22
|
+
usePressAndHold: () => usePressAndHold
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(usePressAndHold_exports);
|
|
25
|
+
function isTouchLikePointerType(pointerType) {
|
|
26
|
+
return pointerType === "touch" || pointerType === "pen";
|
|
27
|
+
}
|
|
28
|
+
function usePressAndHold(_params) {
|
|
29
|
+
return {
|
|
30
|
+
pointerHandlers: {
|
|
31
|
+
onTouchStart() {
|
|
32
|
+
},
|
|
33
|
+
onTouchEnd() {
|
|
34
|
+
},
|
|
35
|
+
onPointerDown() {
|
|
36
|
+
},
|
|
37
|
+
onPointerUp() {
|
|
38
|
+
},
|
|
39
|
+
onPointerMove() {
|
|
40
|
+
},
|
|
41
|
+
onPointerLeave() {
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
shouldSkipClick: () => false
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
isTouchLikePointerType,
|
|
50
|
+
usePressAndHold
|
|
51
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var usePreviousValue_exports = {};
|
|
20
|
+
__export(usePreviousValue_exports, {
|
|
21
|
+
usePreviousValue: () => usePreviousValue
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(usePreviousValue_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../internal.cjs");
|
|
26
|
+
function previousCommittedValue(_current, previous) {
|
|
27
|
+
return previous === void 0 ? null : previous.source;
|
|
28
|
+
}
|
|
29
|
+
const PREVIOUS_VALUE_OPTIONS = {
|
|
30
|
+
sourceEqual: (previous, next) => previous === next
|
|
31
|
+
};
|
|
32
|
+
function usePreviousValue(...args) {
|
|
33
|
+
const [user, slotArg] = (0, import_internal.splitSlot)(args);
|
|
34
|
+
const slot = slotArg ?? (0, import_internal.S)("usePreviousValue");
|
|
35
|
+
const value = user[0];
|
|
36
|
+
const [previous] = (0, import_octane.useLinkedState)(
|
|
37
|
+
value,
|
|
38
|
+
previousCommittedValue,
|
|
39
|
+
PREVIOUS_VALUE_OPTIONS,
|
|
40
|
+
(0, import_internal.subSlot)(slot, "st")
|
|
41
|
+
);
|
|
42
|
+
return previous;
|
|
43
|
+
}
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
usePreviousValue
|
|
47
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useRefWithInit_exports = {};
|
|
20
|
+
__export(useRefWithInit_exports, {
|
|
21
|
+
useRefWithInit: () => useRefWithInit
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useRefWithInit_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../internal.cjs");
|
|
26
|
+
const UNSET = /* @__PURE__ */ Symbol("base-ui.useRefWithInit.unset");
|
|
27
|
+
function useRefWithInit(...args) {
|
|
28
|
+
const [user, slotArg] = (0, import_internal.splitSlot)(args);
|
|
29
|
+
const slot = slotArg ?? (0, import_internal.S)("useRefWithInit");
|
|
30
|
+
const init = user[0];
|
|
31
|
+
const arg = user[1];
|
|
32
|
+
const ref = (0, import_octane.useRef)(UNSET, (0, import_internal.subSlot)(slot, "ref"));
|
|
33
|
+
if (ref.current === UNSET) {
|
|
34
|
+
ref.current = init(arg);
|
|
35
|
+
}
|
|
36
|
+
return ref;
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
useRefWithInit
|
|
41
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useRegisteredLabelId_exports = {};
|
|
20
|
+
__export(useRegisteredLabelId_exports, {
|
|
21
|
+
useRegisteredLabelId: () => useRegisteredLabelId
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useRegisteredLabelId_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../internal.cjs");
|
|
26
|
+
var import_useBaseUiId = require("./useBaseUiId.cjs");
|
|
27
|
+
function useRegisteredLabelId(...args) {
|
|
28
|
+
const [user, slotArg] = (0, import_internal.splitSlot)(args);
|
|
29
|
+
const slot = slotArg ?? (0, import_internal.S)("useRegisteredLabelId");
|
|
30
|
+
const idProp = user[0];
|
|
31
|
+
const setLabelId = user[1];
|
|
32
|
+
const id = (0, import_useBaseUiId.useBaseUiId)(idProp, (0, import_internal.subSlot)(slot, "id"));
|
|
33
|
+
(0, import_octane.useLayoutEffect)(
|
|
34
|
+
() => {
|
|
35
|
+
setLabelId(id);
|
|
36
|
+
return () => {
|
|
37
|
+
setLabelId(void 0);
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
[id, setLabelId],
|
|
41
|
+
(0, import_internal.subSlot)(slot, "e:label")
|
|
42
|
+
);
|
|
43
|
+
return id;
|
|
44
|
+
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
useRegisteredLabelId
|
|
48
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useRenderElement_exports = {};
|
|
20
|
+
__export(useRenderElement_exports, {
|
|
21
|
+
useRenderElement: () => useRenderElement
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useRenderElement_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../internal.cjs");
|
|
26
|
+
var import_composeRefs = require("./composeRefs.cjs");
|
|
27
|
+
var import_getElementRef = require("./getElementRef.cjs");
|
|
28
|
+
var import_getStateAttributesProps = require("./getStateAttributesProps.cjs");
|
|
29
|
+
var import_mergeObjects = require("./mergeObjects.cjs");
|
|
30
|
+
var import_resolveClassName = require("./resolveClassName.cjs");
|
|
31
|
+
var import_resolveStyle = require("./resolveStyle.cjs");
|
|
32
|
+
var import_mergeProps = require("./mergeProps.cjs");
|
|
33
|
+
const EMPTY_OBJECT = {};
|
|
34
|
+
function useRenderElement(element, componentProps, params = {}, ...slotArgs) {
|
|
35
|
+
const [, slotArg] = (0, import_internal.splitSlot)(["_", ...slotArgs]);
|
|
36
|
+
const slot = slotArg ?? (0, import_internal.S)("useRenderElement");
|
|
37
|
+
const renderProp = componentProps.render;
|
|
38
|
+
const outProps = useRenderElementProps(componentProps, params, (0, import_internal.subSlot)(slot, "rp"));
|
|
39
|
+
if (params.enabled === false) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const state = params.state ?? EMPTY_OBJECT;
|
|
43
|
+
return evaluateRenderProp(element, renderProp, outProps, state);
|
|
44
|
+
}
|
|
45
|
+
function useRenderElementProps(componentProps, params, slot) {
|
|
46
|
+
const { className: classNameProp, style: styleProp, render: renderProp } = componentProps;
|
|
47
|
+
const {
|
|
48
|
+
state = EMPTY_OBJECT,
|
|
49
|
+
ref,
|
|
50
|
+
props,
|
|
51
|
+
stateAttributesMapping,
|
|
52
|
+
enabled = true
|
|
53
|
+
} = params;
|
|
54
|
+
const className = enabled ? (0, import_resolveClassName.resolveClassName)(classNameProp, state) : void 0;
|
|
55
|
+
const style = enabled ? (0, import_resolveStyle.resolveStyle)(styleProp, state) : void 0;
|
|
56
|
+
const stateProps = enabled ? (0, import_getStateAttributesProps.getStateAttributesProps)(state, stateAttributesMapping) : EMPTY_OBJECT;
|
|
57
|
+
const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
|
|
58
|
+
const outProps = enabled ? (0, import_mergeObjects.mergeObjects)(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
|
|
59
|
+
const renderRef = (0, import_getElementRef.getElementRef)(renderProp);
|
|
60
|
+
const refs = Array.isArray(ref) ? [outProps.ref, renderRef, ...ref] : [outProps.ref, renderRef, ref];
|
|
61
|
+
const composedRef = (0, import_composeRefs.useComposedRefs)(...refs, (0, import_internal.subSlot)(slot, "refs"));
|
|
62
|
+
if (!enabled) {
|
|
63
|
+
return EMPTY_OBJECT;
|
|
64
|
+
}
|
|
65
|
+
outProps.ref = composedRef;
|
|
66
|
+
if (className !== void 0) {
|
|
67
|
+
outProps.className = (0, import_mergeProps.mergeClassNames)(outProps.className, className);
|
|
68
|
+
}
|
|
69
|
+
if (style !== void 0) {
|
|
70
|
+
outProps.style = (0, import_mergeObjects.mergeObjects)(outProps.style, style);
|
|
71
|
+
}
|
|
72
|
+
return outProps;
|
|
73
|
+
}
|
|
74
|
+
function evaluateRenderProp(element, render, props, state) {
|
|
75
|
+
if (render) {
|
|
76
|
+
if (typeof render === "function") {
|
|
77
|
+
return render(props, state);
|
|
78
|
+
}
|
|
79
|
+
const mergedProps = (0, import_mergeProps.mergeProps)(props, render.props);
|
|
80
|
+
mergedProps.ref = props.ref;
|
|
81
|
+
return (0, import_octane.cloneElement)(render, mergedProps);
|
|
82
|
+
}
|
|
83
|
+
if (element) {
|
|
84
|
+
return renderTag(element, props);
|
|
85
|
+
}
|
|
86
|
+
throw new Error("Base UI: render element or function are not defined.");
|
|
87
|
+
}
|
|
88
|
+
function resolveRenderFunctionProps(props) {
|
|
89
|
+
if (Array.isArray(props)) {
|
|
90
|
+
return (0, import_mergeProps.mergePropsN)(props);
|
|
91
|
+
}
|
|
92
|
+
return (0, import_mergeProps.mergeProps)(void 0, props);
|
|
93
|
+
}
|
|
94
|
+
function renderTag(tag, props) {
|
|
95
|
+
if (tag === "button") {
|
|
96
|
+
return (0, import_octane.createElement)("button", { type: "button", ...props });
|
|
97
|
+
}
|
|
98
|
+
if (tag === "img") {
|
|
99
|
+
return (0, import_octane.createElement)("img", { alt: "", ...props });
|
|
100
|
+
}
|
|
101
|
+
return (0, import_octane.createElement)(tag, props);
|
|
102
|
+
}
|
|
103
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
+
0 && (module.exports = {
|
|
105
|
+
useRenderElement
|
|
106
|
+
});
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useScrollLock_exports = {};
|
|
20
|
+
__export(useScrollLock_exports, {
|
|
21
|
+
useScrollLock: () => useScrollLock
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useScrollLock_exports);
|
|
24
|
+
var import_dom = require("@floating-ui/utils/dom");
|
|
25
|
+
var import_octane = require("octane");
|
|
26
|
+
var import_addEventListener = require("./addEventListener.cjs");
|
|
27
|
+
var import_platform = require("./platform.cjs");
|
|
28
|
+
var import_owner = require("./owner.cjs");
|
|
29
|
+
var import_useTimeout = require("./useTimeout.cjs");
|
|
30
|
+
var import_useAnimationFrame = require("./useAnimationFrame.cjs");
|
|
31
|
+
var import_empty = require("./empty.cjs");
|
|
32
|
+
let originalHtmlStyles = {};
|
|
33
|
+
let originalBodyStyles = {};
|
|
34
|
+
let originalHtmlScrollBehavior = "";
|
|
35
|
+
function hasInsetScrollbars(referenceElement) {
|
|
36
|
+
if (typeof document === "undefined") {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const doc = (0, import_owner.ownerDocument)(referenceElement);
|
|
40
|
+
const win = (0, import_owner.ownerWindow)(doc);
|
|
41
|
+
return win.innerWidth - doc.documentElement.clientWidth > 0;
|
|
42
|
+
}
|
|
43
|
+
function supportsStableScrollbarGutter(referenceElement) {
|
|
44
|
+
const supported = typeof CSS !== "undefined" && CSS.supports && CSS.supports("scrollbar-gutter", "stable");
|
|
45
|
+
if (!supported || typeof document === "undefined") {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const doc = (0, import_owner.ownerDocument)(referenceElement);
|
|
49
|
+
const html = doc.documentElement;
|
|
50
|
+
const body = doc.body;
|
|
51
|
+
const scrollContainer = (0, import_dom.isOverflowElement)(html) ? html : body;
|
|
52
|
+
const originalScrollContainerOverflowY = scrollContainer.style.overflowY;
|
|
53
|
+
const originalHtmlStyleGutter = html.style.scrollbarGutter;
|
|
54
|
+
html.style.scrollbarGutter = "stable";
|
|
55
|
+
scrollContainer.style.overflowY = "scroll";
|
|
56
|
+
const before = scrollContainer.offsetWidth;
|
|
57
|
+
scrollContainer.style.overflowY = "hidden";
|
|
58
|
+
const after = scrollContainer.offsetWidth;
|
|
59
|
+
scrollContainer.style.overflowY = originalScrollContainerOverflowY;
|
|
60
|
+
html.style.scrollbarGutter = originalHtmlStyleGutter;
|
|
61
|
+
return before === after;
|
|
62
|
+
}
|
|
63
|
+
function preventScrollOverlayScrollbars(referenceElement) {
|
|
64
|
+
const doc = (0, import_owner.ownerDocument)(referenceElement);
|
|
65
|
+
const html = doc.documentElement;
|
|
66
|
+
const body = doc.body;
|
|
67
|
+
const elementToLock = (0, import_dom.isOverflowElement)(html) ? html : body;
|
|
68
|
+
const originalElementToLockStyles = {
|
|
69
|
+
overflowY: elementToLock.style.overflowY,
|
|
70
|
+
overflowX: elementToLock.style.overflowX
|
|
71
|
+
};
|
|
72
|
+
Object.assign(elementToLock.style, { overflowY: "hidden", overflowX: "hidden" });
|
|
73
|
+
return () => {
|
|
74
|
+
Object.assign(elementToLock.style, originalElementToLockStyles);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function preventScrollInsetScrollbars(referenceElement) {
|
|
78
|
+
const doc = (0, import_owner.ownerDocument)(referenceElement);
|
|
79
|
+
const html = doc.documentElement;
|
|
80
|
+
const body = doc.body;
|
|
81
|
+
const win = (0, import_owner.ownerWindow)(html);
|
|
82
|
+
let scrollTop = 0;
|
|
83
|
+
let scrollLeft = 0;
|
|
84
|
+
let updateGutterOnly = false;
|
|
85
|
+
const resizeFrame = import_useAnimationFrame.AnimationFrame.create();
|
|
86
|
+
if (import_platform.platform.engine.webkit && (win.visualViewport?.scale ?? 1) !== 1) {
|
|
87
|
+
return () => {
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function lockScroll() {
|
|
91
|
+
const htmlStyles = win.getComputedStyle(html);
|
|
92
|
+
const bodyStyles = win.getComputedStyle(body);
|
|
93
|
+
const htmlScrollbarGutterValue = htmlStyles.scrollbarGutter || "";
|
|
94
|
+
const hasBothEdges = htmlScrollbarGutterValue.includes("both-edges");
|
|
95
|
+
const scrollbarGutterValue = hasBothEdges ? "stable both-edges" : "stable";
|
|
96
|
+
scrollTop = html.scrollTop;
|
|
97
|
+
scrollLeft = html.scrollLeft;
|
|
98
|
+
originalHtmlStyles = {
|
|
99
|
+
scrollbarGutter: html.style.scrollbarGutter,
|
|
100
|
+
overflowY: html.style.overflowY,
|
|
101
|
+
overflowX: html.style.overflowX
|
|
102
|
+
};
|
|
103
|
+
originalHtmlScrollBehavior = html.style.scrollBehavior;
|
|
104
|
+
originalBodyStyles = {
|
|
105
|
+
position: body.style.position,
|
|
106
|
+
height: body.style.height,
|
|
107
|
+
width: body.style.width,
|
|
108
|
+
boxSizing: body.style.boxSizing,
|
|
109
|
+
overflowY: body.style.overflowY,
|
|
110
|
+
overflowX: body.style.overflowX,
|
|
111
|
+
scrollBehavior: body.style.scrollBehavior
|
|
112
|
+
};
|
|
113
|
+
const isScrollableY = html.scrollHeight > html.clientHeight;
|
|
114
|
+
const isScrollableX = html.scrollWidth > html.clientWidth;
|
|
115
|
+
const hasConstantOverflowY = htmlStyles.overflowY === "scroll" || bodyStyles.overflowY === "scroll";
|
|
116
|
+
const hasConstantOverflowX = htmlStyles.overflowX === "scroll" || bodyStyles.overflowX === "scroll";
|
|
117
|
+
const scrollbarWidth = Math.max(0, win.innerWidth - body.clientWidth);
|
|
118
|
+
const scrollbarHeight = Math.max(0, win.innerHeight - body.clientHeight);
|
|
119
|
+
const marginY = parseFloat(bodyStyles.marginTop) + parseFloat(bodyStyles.marginBottom);
|
|
120
|
+
const marginX = parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight);
|
|
121
|
+
const elementToLock = (0, import_dom.isOverflowElement)(html) ? html : body;
|
|
122
|
+
updateGutterOnly = supportsStableScrollbarGutter(referenceElement);
|
|
123
|
+
if (updateGutterOnly) {
|
|
124
|
+
html.style.scrollbarGutter = scrollbarGutterValue;
|
|
125
|
+
elementToLock.style.overflowY = "hidden";
|
|
126
|
+
elementToLock.style.overflowX = "hidden";
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
Object.assign(html.style, {
|
|
130
|
+
scrollbarGutter: scrollbarGutterValue,
|
|
131
|
+
overflowY: "hidden",
|
|
132
|
+
overflowX: "hidden"
|
|
133
|
+
});
|
|
134
|
+
if (isScrollableY || hasConstantOverflowY) {
|
|
135
|
+
html.style.overflowY = "scroll";
|
|
136
|
+
}
|
|
137
|
+
if (isScrollableX || hasConstantOverflowX) {
|
|
138
|
+
html.style.overflowX = "scroll";
|
|
139
|
+
}
|
|
140
|
+
Object.assign(body.style, {
|
|
141
|
+
position: "relative",
|
|
142
|
+
height: marginY || scrollbarHeight ? `calc(100dvh - ${marginY + scrollbarHeight}px)` : "100dvh",
|
|
143
|
+
width: marginX || scrollbarWidth ? `calc(100vw - ${marginX + scrollbarWidth}px)` : "100vw",
|
|
144
|
+
boxSizing: "border-box",
|
|
145
|
+
overflow: "hidden",
|
|
146
|
+
scrollBehavior: "unset"
|
|
147
|
+
});
|
|
148
|
+
body.scrollTop = scrollTop;
|
|
149
|
+
body.scrollLeft = scrollLeft;
|
|
150
|
+
html.setAttribute("data-base-ui-scroll-locked", "");
|
|
151
|
+
html.style.scrollBehavior = "unset";
|
|
152
|
+
}
|
|
153
|
+
function cleanup() {
|
|
154
|
+
Object.assign(html.style, originalHtmlStyles);
|
|
155
|
+
Object.assign(body.style, originalBodyStyles);
|
|
156
|
+
if (!updateGutterOnly) {
|
|
157
|
+
html.scrollTop = scrollTop;
|
|
158
|
+
html.scrollLeft = scrollLeft;
|
|
159
|
+
html.removeAttribute("data-base-ui-scroll-locked");
|
|
160
|
+
html.style.scrollBehavior = originalHtmlScrollBehavior;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function handleResize() {
|
|
164
|
+
cleanup();
|
|
165
|
+
resizeFrame.request(lockScroll);
|
|
166
|
+
}
|
|
167
|
+
lockScroll();
|
|
168
|
+
const unsubscribeResize = (0, import_addEventListener.addEventListener)(win, "resize", handleResize);
|
|
169
|
+
return () => {
|
|
170
|
+
resizeFrame.cancel();
|
|
171
|
+
cleanup();
|
|
172
|
+
if (typeof win.removeEventListener === "function") {
|
|
173
|
+
unsubscribeResize();
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
class ScrollLocker {
|
|
178
|
+
lockCount = 0;
|
|
179
|
+
restore = null;
|
|
180
|
+
timeoutLock = import_useTimeout.Timeout.create();
|
|
181
|
+
timeoutUnlock = import_useTimeout.Timeout.create();
|
|
182
|
+
acquire(referenceElement) {
|
|
183
|
+
this.lockCount += 1;
|
|
184
|
+
if (this.lockCount === 1 && this.restore === null) {
|
|
185
|
+
this.timeoutLock.start(0, () => this.lock(referenceElement));
|
|
186
|
+
}
|
|
187
|
+
return this.release;
|
|
188
|
+
}
|
|
189
|
+
release = () => {
|
|
190
|
+
this.lockCount -= 1;
|
|
191
|
+
if (this.lockCount === 0 && this.restore) {
|
|
192
|
+
this.timeoutUnlock.start(0, this.unlock);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
unlock = () => {
|
|
196
|
+
if (this.lockCount === 0 && this.restore) {
|
|
197
|
+
this.restore?.();
|
|
198
|
+
this.restore = null;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
lock(referenceElement) {
|
|
202
|
+
if (this.lockCount === 0 || this.restore !== null) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const doc = (0, import_owner.ownerDocument)(referenceElement);
|
|
206
|
+
const html = doc.documentElement;
|
|
207
|
+
const htmlOverflowY = (0, import_owner.ownerWindow)(html).getComputedStyle(html).overflowY;
|
|
208
|
+
if (htmlOverflowY === "hidden" || htmlOverflowY === "clip") {
|
|
209
|
+
this.restore = import_empty.NOOP;
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const hasOverlayScrollbars = import_platform.platform.os.ios || !hasInsetScrollbars(referenceElement);
|
|
213
|
+
this.restore = hasOverlayScrollbars ? preventScrollOverlayScrollbars(referenceElement) : preventScrollInsetScrollbars(referenceElement);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const SCROLL_LOCKER = new ScrollLocker();
|
|
217
|
+
function useScrollLock(enabled, referenceElement, slot) {
|
|
218
|
+
(0, import_octane.useLayoutEffect)(
|
|
219
|
+
() => {
|
|
220
|
+
if (!enabled) {
|
|
221
|
+
return void 0;
|
|
222
|
+
}
|
|
223
|
+
return SCROLL_LOCKER.acquire(referenceElement);
|
|
224
|
+
},
|
|
225
|
+
[enabled, referenceElement],
|
|
226
|
+
slot
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
230
|
+
0 && (module.exports = {
|
|
231
|
+
useScrollLock
|
|
232
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var useStableCallback_exports = {};
|
|
20
|
+
__export(useStableCallback_exports, {
|
|
21
|
+
useStableCallback: () => useStableCallback
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(useStableCallback_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../internal.cjs");
|
|
26
|
+
function useStableCallback(...args) {
|
|
27
|
+
const [user, slotArg] = (0, import_internal.splitSlot)(args);
|
|
28
|
+
const slot = slotArg ?? (0, import_internal.S)("useStableCallback");
|
|
29
|
+
const callback = user[0];
|
|
30
|
+
const ref = (0, import_octane.useRef)(void 0, (0, import_internal.subSlot)(slot, "ref"));
|
|
31
|
+
ref.current = callback;
|
|
32
|
+
return (0, import_octane.useCallback)(
|
|
33
|
+
((...a) => ref.current == null ? void 0 : ref.current(...a)),
|
|
34
|
+
[],
|
|
35
|
+
(0, import_internal.subSlot)(slot, "cb")
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
useStableCallback
|
|
41
|
+
});
|