@monimesl/dot-renderer-react 0.1.0-alpha.10
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/README.md +43 -0
- package/dist/LICENSE-PHOSPHOR +21 -0
- package/dist/_virtual/_rolldown/runtime.js +14 -0
- package/dist/_virtual/builtin_esm-external-require-react.js +9 -0
- package/dist/color.js +105 -0
- package/dist/components/amount-input.d.ts +6 -0
- package/dist/components/amount-input.js +106 -0
- package/dist/components/button.d.ts +6 -0
- package/dist/components/button.js +42 -0
- package/dist/components/carousel.d.ts +6 -0
- package/dist/components/carousel.js +254 -0
- package/dist/components/chip.d.ts +6 -0
- package/dist/components/chip.js +41 -0
- package/dist/components/code-input.d.ts +6 -0
- package/dist/components/code-input.js +97 -0
- package/dist/components/detail-row.d.ts +6 -0
- package/dist/components/detail-row.js +40 -0
- package/dist/components/divider.d.ts +6 -0
- package/dist/components/divider.js +18 -0
- package/dist/components/empty-state.d.ts +6 -0
- package/dist/components/empty-state.js +66 -0
- package/dist/components/feedback.d.ts +8 -0
- package/dist/components/feedback.js +85 -0
- package/dist/components/field-box.js +44 -0
- package/dist/components/field.js +43 -0
- package/dist/components/footer.d.ts +6 -0
- package/dist/components/footer.js +24 -0
- package/dist/components/grid.d.ts +7 -0
- package/dist/components/grid.js +98 -0
- package/dist/components/icon-artwork.js +74 -0
- package/dist/components/icon.d.ts +6 -0
- package/dist/components/icon.js +40 -0
- package/dist/components/image.d.ts +6 -0
- package/dist/components/image.js +40 -0
- package/dist/components/index.d.ts +30 -0
- package/dist/components/index.js +72 -0
- package/dist/components/input.d.ts +6 -0
- package/dist/components/input.js +86 -0
- package/dist/components/link.d.ts +6 -0
- package/dist/components/link.js +39 -0
- package/dist/components/list.d.ts +7 -0
- package/dist/components/list.js +143 -0
- package/dist/components/option-place.js +9 -0
- package/dist/components/option.d.ts +6 -0
- package/dist/components/option.js +43 -0
- package/dist/components/padding.d.ts +2 -0
- package/dist/components/padding.js +27 -0
- package/dist/components/pressable.js +17 -0
- package/dist/components/qr-code.d.ts +6 -0
- package/dist/components/qr-code.js +58 -0
- package/dist/components/scroll.d.ts +6 -0
- package/dist/components/scroll.js +55 -0
- package/dist/components/select.d.ts +6 -0
- package/dist/components/select.js +92 -0
- package/dist/components/sheet.d.ts +8 -0
- package/dist/components/sheet.js +105 -0
- package/dist/components/skeleton.d.ts +6 -0
- package/dist/components/skeleton.js +55 -0
- package/dist/components/spinner.d.ts +6 -0
- package/dist/components/spinner.js +48 -0
- package/dist/components/tabs.d.ts +7 -0
- package/dist/components/tabs.js +91 -0
- package/dist/components/text-area.d.ts +6 -0
- package/dist/components/text-area.js +42 -0
- package/dist/components/text.d.ts +6 -0
- package/dist/components/text.js +46 -0
- package/dist/components/toast.d.ts +6 -0
- package/dist/components/toast.js +56 -0
- package/dist/components/toggles.d.ts +9 -0
- package/dist/components/toggles.js +149 -0
- package/dist/components/tokens.js +37 -0
- package/dist/components/tones.js +24 -0
- package/dist/components/typed-text.js +28 -0
- package/dist/components/view.d.ts +6 -0
- package/dist/components/view.js +51 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +35 -0
- package/dist/page-root.d.ts +2 -0
- package/dist/page-root.js +20 -0
- package/dist/portal.js +8 -0
- package/dist/react-host/19.3.0/react-dom-client.js +3 -0
- package/dist/react-host/19.3.0/react-dom.js +3 -0
- package/dist/react-host/19.3.0/react-host.js +59 -0
- package/dist/react-host/19.3.0/react-jsx-runtime.js +3 -0
- package/dist/react-host/19.3.0/react.js +3 -0
- package/dist/renderer.d.ts +17 -0
- package/dist/renderer.js +33 -0
- package/dist/root.d.ts +10 -0
- package/dist/root.js +51 -0
- package/dist/styles.css +95 -0
- package/dist/theme.d.ts +25 -0
- package/dist/theme.js +84 -0
- package/dist/types.d.ts +7 -0
- package/dist/vendor/@base-ui/react/checkbox/indicator/CheckboxIndicator.js +51 -0
- package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRoot.js +265 -0
- package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/checkbox/utils/getCheckboxStateAttributesMapping.js +15 -0
- package/dist/vendor/@base-ui/react/checkbox-group/CheckboxGroupContext.js +10 -0
- package/dist/vendor/@base-ui/react/dialog/backdrop/DialogBackdrop.js +40 -0
- package/dist/vendor/@base-ui/react/dialog/close/DialogClose.js +39 -0
- package/dist/vendor/@base-ui/react/dialog/popup/DialogPopup.js +92 -0
- package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupCssVars.js +8 -0
- package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupDataAttributes.js +7 -0
- package/dist/vendor/@base-ui/react/dialog/portal/DialogPortal.js +38 -0
- package/dist/vendor/@base-ui/react/dialog/portal/DialogPortalContext.js +13 -0
- package/dist/vendor/@base-ui/react/dialog/root/DialogRoot.js +16 -0
- package/dist/vendor/@base-ui/react/dialog/root/DialogRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/dialog/root/useDialogRoot.js +77 -0
- package/dist/vendor/@base-ui/react/dialog/root/useRenderDialogRoot.js +65 -0
- package/dist/vendor/@base-ui/react/dialog/store/DialogStore.js +70 -0
- package/dist/vendor/@base-ui/react/dialog/title/DialogTitle.js +25 -0
- package/dist/vendor/@base-ui/react/dialog/utils/stateAttributesMapping.js +17 -0
- package/dist/vendor/@base-ui/react/field/control/FieldControlDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/field/item/FieldItemContext.js +10 -0
- package/dist/vendor/@base-ui/react/field/root/useFieldValidation.js +18 -0
- package/dist/vendor/@base-ui/react/fieldset/root/FieldsetRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingFocusManager.js +477 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingPortal.js +165 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingRootStore.js +65 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingTree.js +22 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useDismiss.js +373 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.js +58 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/composite.js +40 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/constants.js +5 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/createAttribute.js +6 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/createEventEmitter.js +18 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/element.js +26 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/enqueueFocus.js +25 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/event.js +25 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/markOthers.js +116 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/nodes.js +16 -0
- package/dist/vendor/@base-ui/react/floating-ui-react/utils/tabbable.js +135 -0
- package/dist/vendor/@base-ui/react/internals/TransitionStatusDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/internals/composite/composite.js +89 -0
- package/dist/vendor/@base-ui/react/internals/composite/constants.js +4 -0
- package/dist/vendor/@base-ui/react/internals/composite/item/CompositeItem.js +21 -0
- package/dist/vendor/@base-ui/react/internals/composite/item/useCompositeItem.js +31 -0
- package/dist/vendor/@base-ui/react/internals/composite/list/CompositeList.js +180 -0
- package/dist/vendor/@base-ui/react/internals/composite/list/CompositeListContext.js +15 -0
- package/dist/vendor/@base-ui/react/internals/composite/list/useCompositeListItem.js +54 -0
- package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRoot.js +62 -0
- package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/internals/composite/root/useCompositeRoot.js +170 -0
- package/dist/vendor/@base-ui/react/internals/constants.js +18 -0
- package/dist/vendor/@base-ui/react/internals/createBaseUIEventDetails.js +40 -0
- package/dist/vendor/@base-ui/react/internals/direction-context/DirectionContext.js +10 -0
- package/dist/vendor/@base-ui/react/internals/field-constants/constants.js +33 -0
- package/dist/vendor/@base-ui/react/internals/field-register-control/useRegisterFieldControl.js +40 -0
- package/dist/vendor/@base-ui/react/internals/field-root-context/FieldRootContext.js +45 -0
- package/dist/vendor/@base-ui/react/internals/form-context/FormContext.js +18 -0
- package/dist/vendor/@base-ui/react/internals/getStateAttributesProps.js +17 -0
- package/dist/vendor/@base-ui/react/internals/labelable-provider/LabelableContext.js +24 -0
- package/dist/vendor/@base-ui/react/internals/labelable-provider/useAriaLabelledBy.js +35 -0
- package/dist/vendor/@base-ui/react/internals/labelable-provider/useLabelableId.js +57 -0
- package/dist/vendor/@base-ui/react/internals/reason-parts.js +14 -0
- package/dist/vendor/@base-ui/react/internals/serializeValue.js +12 -0
- package/dist/vendor/@base-ui/react/internals/stateAttributesMapping.js +11 -0
- package/dist/vendor/@base-ui/react/internals/use-button/useButton.js +137 -0
- package/dist/vendor/@base-ui/react/internals/useAnimationsFinished.js +94 -0
- package/dist/vendor/@base-ui/react/internals/useBaseUiId.js +13 -0
- package/dist/vendor/@base-ui/react/internals/useOpenChangeComplete.js +28 -0
- package/dist/vendor/@base-ui/react/internals/useRenderElement.js +109 -0
- package/dist/vendor/@base-ui/react/internals/useTransitionStatus.js +70 -0
- package/dist/vendor/@base-ui/react/internals/useValueChanged.js +15 -0
- package/dist/vendor/@base-ui/react/merge-props/mergeProps.js +153 -0
- package/dist/vendor/@base-ui/react/radio/indicator/RadioIndicator.js +46 -0
- package/dist/vendor/@base-ui/react/radio/root/RadioRoot.js +179 -0
- package/dist/vendor/@base-ui/react/radio/root/RadioRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/radio/root/RadioRootDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/radio/utils/stateAttributesMapping.js +14 -0
- package/dist/vendor/@base-ui/react/radio-group/RadioGroup.js +170 -0
- package/dist/vendor/@base-ui/react/radio-group/RadioGroupContext.js +10 -0
- package/dist/vendor/@base-ui/react/switch/root/SwitchRoot.js +170 -0
- package/dist/vendor/@base-ui/react/switch/root/SwitchRootContext.js +13 -0
- package/dist/vendor/@base-ui/react/switch/root/SwitchRootDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/switch/stateAttributesMapping.js +12 -0
- package/dist/vendor/@base-ui/react/switch/thumb/SwitchThumb.js +25 -0
- package/dist/vendor/@base-ui/react/tabs/list/TabsList.js +98 -0
- package/dist/vendor/@base-ui/react/tabs/list/TabsListContext.js +13 -0
- package/dist/vendor/@base-ui/react/tabs/root/TabsRoot.js +213 -0
- package/dist/vendor/@base-ui/react/tabs/root/TabsRootContext.js +16 -0
- package/dist/vendor/@base-ui/react/tabs/root/TabsRootDataAttributes.js +8 -0
- package/dist/vendor/@base-ui/react/tabs/root/stateAttributesMapping.js +5 -0
- package/dist/vendor/@base-ui/react/tabs/tab/TabsTab.js +137 -0
- package/dist/vendor/@base-ui/react/utils/CommonPopupDataAttributes.js +24 -0
- package/dist/vendor/@base-ui/react/utils/CommonTriggerDataAttributes.js +11 -0
- package/dist/vendor/@base-ui/react/utils/FocusGuard.js +32 -0
- package/dist/vendor/@base-ui/react/utils/InternalBackdrop.js +30 -0
- package/dist/vendor/@base-ui/react/utils/dispatchClickWithModifiers.js +25 -0
- package/dist/vendor/@base-ui/react/utils/popupStateMapping.js +22 -0
- package/dist/vendor/@base-ui/react/utils/popups/popupStoreUtils.js +247 -0
- package/dist/vendor/@base-ui/react/utils/popups/popupTriggerMap.js +96 -0
- package/dist/vendor/@base-ui/react/utils/popups/store.js +94 -0
- package/dist/vendor/@base-ui/react/utils/resolveClassName.js +13 -0
- package/dist/vendor/@base-ui/react/utils/resolveRef.js +11 -0
- package/dist/vendor/@base-ui/react/utils/resolveStyle.js +13 -0
- package/dist/vendor/@base-ui/react/utils/useFocusableWhenDisabled.js +30 -0
- package/dist/vendor/@base-ui/utils/addEventListener.js +12 -0
- package/dist/vendor/@base-ui/utils/createLogOnce.js +20 -0
- package/dist/vendor/@base-ui/utils/empty.js +6 -0
- package/dist/vendor/@base-ui/utils/error.js +5 -0
- package/dist/vendor/@base-ui/utils/fastHooks.js +68 -0
- package/dist/vendor/@base-ui/utils/formatErrorMessage.js +27 -0
- package/dist/vendor/@base-ui/utils/getDefaultFormSubmitter.js +25 -0
- package/dist/vendor/@base-ui/utils/getReactElementRef.js +14 -0
- package/dist/vendor/@base-ui/utils/inertValue.js +8 -0
- package/dist/vendor/@base-ui/utils/isElementDisabled.js +6 -0
- package/dist/vendor/@base-ui/utils/mergeCleanups.js +14 -0
- package/dist/vendor/@base-ui/utils/mergeObjects.js +11 -0
- package/dist/vendor/@base-ui/utils/owner.js +7 -0
- package/dist/vendor/@base-ui/utils/platform/engine.js +8 -0
- package/dist/vendor/@base-ui/utils/platform/env.js +6 -0
- package/dist/vendor/@base-ui/utils/platform/os.js +15 -0
- package/dist/vendor/@base-ui/utils/platform/screen-reader.js +9 -0
- package/dist/vendor/@base-ui/utils/platform/shared.js +36 -0
- package/dist/vendor/@base-ui/utils/reactVersion.js +8 -0
- package/dist/vendor/@base-ui/utils/safeReact.js +13 -0
- package/dist/vendor/@base-ui/utils/shadowDom.js +26 -0
- package/dist/vendor/@base-ui/utils/store/ReactStore.js +181 -0
- package/dist/vendor/@base-ui/utils/store/Store.js +102 -0
- package/dist/vendor/@base-ui/utils/store/useStore.js +97 -0
- package/dist/vendor/@base-ui/utils/useAnimationFrame.js +87 -0
- package/dist/vendor/@base-ui/utils/useControlled.js +52 -0
- package/dist/vendor/@base-ui/utils/useId.js +32 -0
- package/dist/vendor/@base-ui/utils/useIsoLayoutEffect.js +7 -0
- package/dist/vendor/@base-ui/utils/useMergedRefs.js +87 -0
- package/dist/vendor/@base-ui/utils/useOnMount.js +12 -0
- package/dist/vendor/@base-ui/utils/useRefWithInit.js +18 -0
- package/dist/vendor/@base-ui/utils/useScrollLock.js +206 -0
- package/dist/vendor/@base-ui/utils/useStableCallback.js +38 -0
- package/dist/vendor/@base-ui/utils/useTimeout.js +43 -0
- package/dist/vendor/@base-ui/utils/useValueAsRef.js +27 -0
- package/dist/vendor/@base-ui/utils/visuallyHidden.js +23 -0
- package/dist/vendor/@base-ui/utils/warn.js +5 -0
- package/dist/vendor/@floating-ui/utils/dist/floating-ui.utils.dom.js +49 -0
- package/dist/vendor/uqr/dist/index.js +858 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +74 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +77 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +69 -0
- package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +64 -0
- package/dist/vendor/use-sync-external-store/shim/index.js +11 -0
- package/dist/vendor/use-sync-external-store/shim/with-selector.js +11 -0
- package/package.json +61 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { isClickLikeEvent } from "../utils/event.js";
|
|
2
|
+
import { createEventEmitter } from "../utils/createEventEmitter.js";
|
|
3
|
+
import { ReactStore } from "../../../utils/store/ReactStore.js";
|
|
4
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs
|
|
5
|
+
const selectors = {
|
|
6
|
+
open: (state) => state.open,
|
|
7
|
+
transitionStatus: (state) => state.transitionStatus,
|
|
8
|
+
domReferenceElement: (state) => state.domReferenceElement,
|
|
9
|
+
referenceElement: (state) => state.positionReference ?? state.referenceElement,
|
|
10
|
+
floatingElement: (state) => state.floatingElement,
|
|
11
|
+
floatingId: (state) => state.floatingId
|
|
12
|
+
};
|
|
13
|
+
var FloatingRootStore = class extends ReactStore {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
const { syncOnly, nested, onOpenChange, triggerElements, ...initialState } = options;
|
|
16
|
+
super({
|
|
17
|
+
...initialState,
|
|
18
|
+
positionReference: initialState.referenceElement,
|
|
19
|
+
domReferenceElement: initialState.referenceElement
|
|
20
|
+
}, {
|
|
21
|
+
onOpenChange,
|
|
22
|
+
dataRef: { current: {} },
|
|
23
|
+
events: createEventEmitter(),
|
|
24
|
+
nested,
|
|
25
|
+
triggerElements
|
|
26
|
+
}, selectors);
|
|
27
|
+
this.syncOnly = syncOnly;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
|
|
31
|
+
*/
|
|
32
|
+
syncOpenEvent = (newOpen, event) => {
|
|
33
|
+
if (!newOpen || !this.state.open || event != null && isClickLikeEvent(event)) this.context.dataRef.current.openEvent = newOpen ? event : void 0;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Runs the root-owned side effects for an open state change.
|
|
37
|
+
*/
|
|
38
|
+
dispatchOpenChange = (newOpen, eventDetails) => {
|
|
39
|
+
this.syncOpenEvent(newOpen, eventDetails.event);
|
|
40
|
+
const details = {
|
|
41
|
+
open: newOpen,
|
|
42
|
+
reason: eventDetails.reason,
|
|
43
|
+
nativeEvent: eventDetails.event,
|
|
44
|
+
nested: this.context.nested,
|
|
45
|
+
triggerElement: eventDetails.trigger
|
|
46
|
+
};
|
|
47
|
+
this.context.events.emit("openchange", details);
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
|
|
51
|
+
*
|
|
52
|
+
* @param newOpen The new open state.
|
|
53
|
+
* @param eventDetails Details about the event that triggered the open state change.
|
|
54
|
+
*/
|
|
55
|
+
setOpen = (newOpen, eventDetails) => {
|
|
56
|
+
if (this.syncOnly) {
|
|
57
|
+
this.context.onOpenChange?.(newOpen, eventDetails);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.dispatchOpenChange(newOpen, eventDetails);
|
|
61
|
+
this.context.onOpenChange?.(newOpen, eventDetails);
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { FloatingRootStore };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import "react/jsx-runtime";
|
|
4
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
|
|
5
|
+
const FloatingNodeContext = /*#__PURE__*/ React.createContext(null);
|
|
6
|
+
if (process.env.NODE_ENV !== "production") FloatingNodeContext.displayName = "FloatingNodeContext";
|
|
7
|
+
const FloatingTreeContext = /*#__PURE__*/ React.createContext(null);
|
|
8
|
+
/**
|
|
9
|
+
* Returns the parent node id for nested floating elements, if available.
|
|
10
|
+
* Returns `null` for top-level floating elements.
|
|
11
|
+
*/
|
|
12
|
+
if (process.env.NODE_ENV !== "production") FloatingTreeContext.displayName = "FloatingTreeContext";
|
|
13
|
+
const useFloatingParentNodeId = () => React.useContext(FloatingNodeContext)?.id || null;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the nearest floating tree context, if available.
|
|
16
|
+
*/
|
|
17
|
+
const useFloatingTree = (externalTree) => {
|
|
18
|
+
const contextTree = React.useContext(FloatingTreeContext);
|
|
19
|
+
return externalTree ?? contextTree;
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { useFloatingParentNodeId, useFloatingTree };
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getComputedStyle, getParentNode, isElement, isHTMLElement, isLastTraversableNode, isShadowRoot } from "../../../../@floating-ui/utils/dist/floating-ui.utils.dom.js";
|
|
3
|
+
import { useStableCallback } from "../../../utils/useStableCallback.js";
|
|
4
|
+
import { ownerDocument } from "../../../utils/owner.js";
|
|
5
|
+
import { escapeKey, outsidePress, triggerPress } from "../../internals/reason-parts.js";
|
|
6
|
+
import { createChangeEventDetails } from "../../internals/createBaseUIEventDetails.js";
|
|
7
|
+
import { Timeout, useTimeout } from "../../../utils/useTimeout.js";
|
|
8
|
+
import { webkit } from "../../../utils/platform/engine.js";
|
|
9
|
+
import { isReactEvent, isVirtualClick } from "../utils/event.js";
|
|
10
|
+
import { contains, getTarget } from "../../../utils/shadowDom.js";
|
|
11
|
+
import { isEventTargetWithin, isRootElement } from "../utils/element.js";
|
|
12
|
+
import { addEventListener } from "../../../utils/addEventListener.js";
|
|
13
|
+
import { mergeCleanups } from "../../../utils/mergeCleanups.js";
|
|
14
|
+
import { getNodeChildren } from "../utils/nodes.js";
|
|
15
|
+
import { createAttribute } from "../utils/createAttribute.js";
|
|
16
|
+
import { useFloatingTree } from "../components/FloatingTree.js";
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs
|
|
19
|
+
function alwaysFalse() {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
function normalizeProp(normalizable) {
|
|
23
|
+
return {
|
|
24
|
+
escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
|
|
25
|
+
outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Closes the floating element when a dismissal is requested — by default, when
|
|
30
|
+
* the user presses the `escape` key or outside of the floating element.
|
|
31
|
+
* @see https://floating-ui.com/docs/useDismiss
|
|
32
|
+
*/
|
|
33
|
+
function useDismiss(context, props = {}) {
|
|
34
|
+
const { enabled = true, escapeKey: escapeKey$1 = true, outsidePress: outsidePressProp = true, outsidePressEvent = "sloppy", referencePress = alwaysFalse, bubbles, externalTree } = props;
|
|
35
|
+
const store = "rootStore" in context ? context.rootStore : context;
|
|
36
|
+
const open = store.useState("open");
|
|
37
|
+
const floatingElement = store.useState("floatingElement");
|
|
38
|
+
const { dataRef, events } = store.context;
|
|
39
|
+
const tree = useFloatingTree(externalTree);
|
|
40
|
+
const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
|
|
41
|
+
const outsidePress$1 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
|
|
42
|
+
const outsidePressEnabled = outsidePress$1 !== false;
|
|
43
|
+
const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
|
|
44
|
+
const { escapeKey: escapeKeyBubbles, outsidePress: outsidePressBubbles } = normalizeProp(bubbles);
|
|
45
|
+
const pressStartedInsideRef = React.useRef(false);
|
|
46
|
+
const pressStartPreventedRef = React.useRef(false);
|
|
47
|
+
const suppressNextOutsideClickRef = React.useRef(false);
|
|
48
|
+
const sawPressWhileOpenRef = React.useRef(false);
|
|
49
|
+
const isComposingRef = React.useRef(false);
|
|
50
|
+
const currentPointerTypeRef = React.useRef("");
|
|
51
|
+
const touchStateRef = React.useRef(null);
|
|
52
|
+
const cancelDismissOnEndTimeout = useTimeout();
|
|
53
|
+
const clearInsideReactTreeTimeout = useTimeout();
|
|
54
|
+
const clearInsideReactTree = useStableCallback(() => {
|
|
55
|
+
clearInsideReactTreeTimeout.clear();
|
|
56
|
+
dataRef.current.insideReactTree = false;
|
|
57
|
+
});
|
|
58
|
+
const hasBlockingChild = useStableCallback((bubbleKey) => {
|
|
59
|
+
const nodeId = dataRef.current.floatingContext?.nodeId;
|
|
60
|
+
return (tree ? getNodeChildren(tree.nodesRef.current, nodeId) : []).some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
|
|
61
|
+
});
|
|
62
|
+
const isEventWithinOwnElements = useStableCallback((event) => {
|
|
63
|
+
return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
|
|
64
|
+
});
|
|
65
|
+
const closeOnReferencePress = useStableCallback((event) => {
|
|
66
|
+
if (!referencePress()) return;
|
|
67
|
+
store.setOpen(false, createChangeEventDetails(triggerPress, event.nativeEvent));
|
|
68
|
+
});
|
|
69
|
+
const closeOnEscapeKeyDown = useStableCallback((event) => {
|
|
70
|
+
if (!open || !enabled || !escapeKey$1 || event.key !== "Escape") return;
|
|
71
|
+
if (isComposingRef.current) return;
|
|
72
|
+
if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) return;
|
|
73
|
+
const native = isReactEvent(event) ? event.nativeEvent : event;
|
|
74
|
+
const eventDetails = createChangeEventDetails(escapeKey, native);
|
|
75
|
+
store.setOpen(false, eventDetails);
|
|
76
|
+
if (!eventDetails.isCanceled) event.preventDefault();
|
|
77
|
+
if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) event.stopPropagation();
|
|
78
|
+
});
|
|
79
|
+
const markInsideReactTree = useStableCallback(() => {
|
|
80
|
+
dataRef.current.insideReactTree = true;
|
|
81
|
+
clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
|
|
82
|
+
});
|
|
83
|
+
const markPressStartedInsideReactTree = useStableCallback((event) => {
|
|
84
|
+
if (!open || !enabled || event.button !== 0) return;
|
|
85
|
+
const target = getTarget(event.nativeEvent);
|
|
86
|
+
if (!contains(store.select("floatingElement"), target)) return;
|
|
87
|
+
if (!pressStartedInsideRef.current) {
|
|
88
|
+
pressStartedInsideRef.current = true;
|
|
89
|
+
pressStartPreventedRef.current = false;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const markInsidePressStartPrevented = useStableCallback((event) => {
|
|
93
|
+
if (!open || !enabled) return;
|
|
94
|
+
if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) return;
|
|
95
|
+
if (pressStartedInsideRef.current) pressStartPreventedRef.current = true;
|
|
96
|
+
});
|
|
97
|
+
React.useEffect(() => {
|
|
98
|
+
function handleOpenChange(details) {
|
|
99
|
+
if (!details.open) sawPressWhileOpenRef.current = false;
|
|
100
|
+
}
|
|
101
|
+
events.on("openchange", handleOpenChange);
|
|
102
|
+
return () => {
|
|
103
|
+
events.off("openchange", handleOpenChange);
|
|
104
|
+
};
|
|
105
|
+
}, [events]);
|
|
106
|
+
React.useEffect(() => {
|
|
107
|
+
if (!open || !enabled) {
|
|
108
|
+
if (!open) sawPressWhileOpenRef.current = false;
|
|
109
|
+
return clearInsideReactTree;
|
|
110
|
+
}
|
|
111
|
+
dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
|
|
112
|
+
dataRef.current.__outsidePressBubbles = outsidePressBubbles;
|
|
113
|
+
const compositionTimeout = new Timeout();
|
|
114
|
+
const preventedPressSuppressionTimeout = new Timeout();
|
|
115
|
+
const doc = ownerDocument(floatingElement);
|
|
116
|
+
function handleCompositionStart() {
|
|
117
|
+
compositionTimeout.clear();
|
|
118
|
+
isComposingRef.current = true;
|
|
119
|
+
}
|
|
120
|
+
function handleCompositionEnd() {
|
|
121
|
+
compositionTimeout.start(webkit ? 5 : 0, () => {
|
|
122
|
+
isComposingRef.current = false;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function suppressImmediateOutsideClickAfterPreventedStart() {
|
|
126
|
+
suppressNextOutsideClickRef.current = true;
|
|
127
|
+
preventedPressSuppressionTimeout.start(0, () => {
|
|
128
|
+
suppressNextOutsideClickRef.current = false;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function resetPressStartState() {
|
|
132
|
+
pressStartedInsideRef.current = false;
|
|
133
|
+
pressStartPreventedRef.current = false;
|
|
134
|
+
}
|
|
135
|
+
function getOutsidePressEvent() {
|
|
136
|
+
const type = currentPointerTypeRef.current;
|
|
137
|
+
const computedType = type === "pen" || !type ? "mouse" : type;
|
|
138
|
+
const outsidePressEventValue = getOutsidePressEventProp();
|
|
139
|
+
const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
|
|
140
|
+
if (typeof resolved === "string") return resolved;
|
|
141
|
+
return resolved[computedType];
|
|
142
|
+
}
|
|
143
|
+
function shouldIgnoreEvent(event) {
|
|
144
|
+
const computedOutsidePressEvent = getOutsidePressEvent();
|
|
145
|
+
return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
|
|
146
|
+
}
|
|
147
|
+
function isEventWithinFloatingTree(event) {
|
|
148
|
+
const nodeId = dataRef.current.floatingContext?.nodeId;
|
|
149
|
+
const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
|
|
150
|
+
return isEventWithinOwnElements(event) || targetIsInsideChildren;
|
|
151
|
+
}
|
|
152
|
+
function closeOnPressOutside(event) {
|
|
153
|
+
if (shouldIgnoreEvent(event)) {
|
|
154
|
+
if (event.type !== "click" && !isEventWithinOwnElements(event)) {
|
|
155
|
+
preventedPressSuppressionTimeout.clear();
|
|
156
|
+
suppressNextOutsideClickRef.current = false;
|
|
157
|
+
}
|
|
158
|
+
clearInsideReactTree();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (dataRef.current.insideReactTree) {
|
|
162
|
+
clearInsideReactTree();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const target = getTarget(event);
|
|
166
|
+
const inertSelector = `[${createAttribute("inert")}]`;
|
|
167
|
+
const targetRoot = isElement(target) ? target.getRootNode() : null;
|
|
168
|
+
const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
|
|
169
|
+
const triggers = store.context.triggerElements;
|
|
170
|
+
if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) return;
|
|
171
|
+
let targetRootAncestor = isElement(target) ? target : null;
|
|
172
|
+
while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
|
|
173
|
+
const nextParent = getParentNode(targetRootAncestor);
|
|
174
|
+
if (isLastTraversableNode(nextParent) || !isElement(nextParent)) break;
|
|
175
|
+
targetRootAncestor = nextParent;
|
|
176
|
+
}
|
|
177
|
+
if (markers.length && isElement(target) && !isRootElement(target) && !contains(target, store.select("floatingElement")) && markers.every((marker) => !contains(targetRootAncestor, marker))) return;
|
|
178
|
+
if (isHTMLElement(target) && !("touches" in event)) {
|
|
179
|
+
const lastTraversableNode = isLastTraversableNode(target);
|
|
180
|
+
const style = getComputedStyle(target);
|
|
181
|
+
const scrollRe = /auto|scroll/;
|
|
182
|
+
const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
|
|
183
|
+
const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
|
|
184
|
+
const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
|
|
185
|
+
const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
|
|
186
|
+
const isRTL = style.direction === "rtl";
|
|
187
|
+
const pressedVerticalScrollbar = canScrollY && (isRTL ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
|
|
188
|
+
const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
|
|
189
|
+
if (pressedVerticalScrollbar || pressedHorizontalScrollbar) return;
|
|
190
|
+
}
|
|
191
|
+
if (isEventWithinFloatingTree(event)) return;
|
|
192
|
+
if (getOutsidePressEvent() === "intentional") {
|
|
193
|
+
if (event.detail !== 0 && !isVirtualClick(event) && !sawPressWhileOpenRef.current) return;
|
|
194
|
+
if (suppressNextOutsideClickRef.current) {
|
|
195
|
+
preventedPressSuppressionTimeout.clear();
|
|
196
|
+
suppressNextOutsideClickRef.current = false;
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (typeof outsidePress$1 === "function" && !outsidePress$1(event)) return;
|
|
201
|
+
if (hasBlockingChild("__outsidePressBubbles")) return;
|
|
202
|
+
store.setOpen(false, createChangeEventDetails(outsidePress, event));
|
|
203
|
+
clearInsideReactTree();
|
|
204
|
+
}
|
|
205
|
+
function handlePointerDown(event) {
|
|
206
|
+
if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) return;
|
|
207
|
+
closeOnPressOutside(event);
|
|
208
|
+
}
|
|
209
|
+
function handleTouchStart(event) {
|
|
210
|
+
if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) return;
|
|
211
|
+
const touch = event.touches[0];
|
|
212
|
+
if (touch) {
|
|
213
|
+
touchStateRef.current = {
|
|
214
|
+
startTime: Date.now(),
|
|
215
|
+
startX: touch.clientX,
|
|
216
|
+
startY: touch.clientY,
|
|
217
|
+
dismissOnTouchEnd: false,
|
|
218
|
+
dismissOnMouseDown: true
|
|
219
|
+
};
|
|
220
|
+
cancelDismissOnEndTimeout.start(1e3, () => {
|
|
221
|
+
if (touchStateRef.current) {
|
|
222
|
+
touchStateRef.current.dismissOnTouchEnd = false;
|
|
223
|
+
touchStateRef.current.dismissOnMouseDown = false;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function addTargetEventListenerOnce(event, listener) {
|
|
229
|
+
const target = getTarget(event);
|
|
230
|
+
if (!target) return;
|
|
231
|
+
const unsubscribe = addEventListener(target, event.type, () => {
|
|
232
|
+
listener(event);
|
|
233
|
+
unsubscribe();
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function handleTouchStartCapture(event) {
|
|
237
|
+
currentPointerTypeRef.current = "touch";
|
|
238
|
+
addTargetEventListenerOnce(event, handleTouchStart);
|
|
239
|
+
}
|
|
240
|
+
function closeOnPressOutsideCapture(event) {
|
|
241
|
+
cancelDismissOnEndTimeout.clear();
|
|
242
|
+
if (event.type === "pointerdown") {
|
|
243
|
+
if (event.button === 0) sawPressWhileOpenRef.current = true;
|
|
244
|
+
currentPointerTypeRef.current = event.pointerType;
|
|
245
|
+
}
|
|
246
|
+
if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) return;
|
|
247
|
+
addTargetEventListenerOnce(event, (targetEvent) => {
|
|
248
|
+
if (targetEvent.type === "pointerdown") handlePointerDown(targetEvent);
|
|
249
|
+
else closeOnPressOutside(targetEvent);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function handlePressEndCapture(event) {
|
|
253
|
+
if (event.type === "pointercancel") sawPressWhileOpenRef.current = false;
|
|
254
|
+
if (!pressStartedInsideRef.current) return;
|
|
255
|
+
const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
|
|
256
|
+
resetPressStartState();
|
|
257
|
+
if (getOutsidePressEvent() !== "intentional") return;
|
|
258
|
+
if (event.type === "pointercancel") {
|
|
259
|
+
if (pressStartedInsideDefaultPrevented) suppressImmediateOutsideClickAfterPreventedStart();
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (isEventWithinFloatingTree(event)) return;
|
|
263
|
+
if (pressStartedInsideDefaultPrevented) {
|
|
264
|
+
suppressImmediateOutsideClickAfterPreventedStart();
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (typeof outsidePress$1 === "function" && !outsidePress$1(event)) return;
|
|
268
|
+
preventedPressSuppressionTimeout.clear();
|
|
269
|
+
suppressNextOutsideClickRef.current = true;
|
|
270
|
+
clearInsideReactTree();
|
|
271
|
+
}
|
|
272
|
+
function handleTouchMove(event) {
|
|
273
|
+
if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) return;
|
|
274
|
+
const touch = event.touches[0];
|
|
275
|
+
if (!touch) return;
|
|
276
|
+
const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
|
|
277
|
+
const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
|
|
278
|
+
const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
|
|
279
|
+
if (distance > 5) touchStateRef.current.dismissOnTouchEnd = true;
|
|
280
|
+
if (distance > 10) {
|
|
281
|
+
closeOnPressOutside(event);
|
|
282
|
+
cancelDismissOnEndTimeout.clear();
|
|
283
|
+
touchStateRef.current = null;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function handleTouchMoveCapture(event) {
|
|
287
|
+
addTargetEventListenerOnce(event, handleTouchMove);
|
|
288
|
+
}
|
|
289
|
+
function handleTouchEnd(event) {
|
|
290
|
+
if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) return;
|
|
291
|
+
if (touchStateRef.current.dismissOnTouchEnd) closeOnPressOutside(event);
|
|
292
|
+
cancelDismissOnEndTimeout.clear();
|
|
293
|
+
touchStateRef.current = null;
|
|
294
|
+
}
|
|
295
|
+
function handleTouchEndCapture(event) {
|
|
296
|
+
addTargetEventListenerOnce(event, handleTouchEnd);
|
|
297
|
+
}
|
|
298
|
+
const unsubscribe = mergeCleanups(escapeKey$1 && mergeCleanups(addEventListener(doc, "keydown", closeOnEscapeKeyDown), addEventListener(doc, "compositionstart", handleCompositionStart), addEventListener(doc, "compositionend", handleCompositionEnd)), outsidePressEnabled && mergeCleanups(addEventListener(doc, "click", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerdown", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerup", handlePressEndCapture, true), addEventListener(doc, "pointercancel", handlePressEndCapture, true), addEventListener(doc, "mousedown", closeOnPressOutsideCapture, true), addEventListener(doc, "mouseup", handlePressEndCapture, true), addEventListener(doc, "touchstart", handleTouchStartCapture, {
|
|
299
|
+
capture: true,
|
|
300
|
+
passive: true
|
|
301
|
+
}), addEventListener(doc, "touchmove", handleTouchMoveCapture, {
|
|
302
|
+
capture: true,
|
|
303
|
+
passive: true
|
|
304
|
+
}), addEventListener(doc, "touchend", handleTouchEndCapture, {
|
|
305
|
+
capture: true,
|
|
306
|
+
passive: true
|
|
307
|
+
})));
|
|
308
|
+
return () => {
|
|
309
|
+
unsubscribe();
|
|
310
|
+
compositionTimeout.clear();
|
|
311
|
+
preventedPressSuppressionTimeout.clear();
|
|
312
|
+
resetPressStartState();
|
|
313
|
+
suppressNextOutsideClickRef.current = false;
|
|
314
|
+
clearInsideReactTree();
|
|
315
|
+
};
|
|
316
|
+
}, [
|
|
317
|
+
dataRef,
|
|
318
|
+
floatingElement,
|
|
319
|
+
escapeKey$1,
|
|
320
|
+
outsidePressEnabled,
|
|
321
|
+
outsidePress$1,
|
|
322
|
+
open,
|
|
323
|
+
enabled,
|
|
324
|
+
escapeKeyBubbles,
|
|
325
|
+
outsidePressBubbles,
|
|
326
|
+
closeOnEscapeKeyDown,
|
|
327
|
+
clearInsideReactTree,
|
|
328
|
+
getOutsidePressEventProp,
|
|
329
|
+
hasBlockingChild,
|
|
330
|
+
isEventWithinOwnElements,
|
|
331
|
+
tree,
|
|
332
|
+
store,
|
|
333
|
+
cancelDismissOnEndTimeout
|
|
334
|
+
]);
|
|
335
|
+
const reference = React.useMemo(() => ({
|
|
336
|
+
onKeyDown: closeOnEscapeKeyDown,
|
|
337
|
+
onPointerDown: closeOnReferencePress,
|
|
338
|
+
onClick: closeOnReferencePress
|
|
339
|
+
}), [closeOnEscapeKeyDown, closeOnReferencePress]);
|
|
340
|
+
const floating = React.useMemo(() => ({
|
|
341
|
+
onKeyDown: closeOnEscapeKeyDown,
|
|
342
|
+
onPointerDown: markInsidePressStartPrevented,
|
|
343
|
+
onMouseDown: markInsidePressStartPrevented,
|
|
344
|
+
onClickCapture: markInsideReactTree,
|
|
345
|
+
onMouseDownCapture(event) {
|
|
346
|
+
markInsideReactTree();
|
|
347
|
+
markPressStartedInsideReactTree(event);
|
|
348
|
+
},
|
|
349
|
+
onPointerDownCapture(event) {
|
|
350
|
+
markInsideReactTree();
|
|
351
|
+
markPressStartedInsideReactTree(event);
|
|
352
|
+
},
|
|
353
|
+
onMouseUpCapture: markInsideReactTree,
|
|
354
|
+
onTouchEndCapture: markInsideReactTree,
|
|
355
|
+
onTouchMoveCapture: markInsideReactTree
|
|
356
|
+
}), [
|
|
357
|
+
closeOnEscapeKeyDown,
|
|
358
|
+
markInsideReactTree,
|
|
359
|
+
markPressStartedInsideReactTree,
|
|
360
|
+
markInsidePressStartPrevented
|
|
361
|
+
]);
|
|
362
|
+
return React.useMemo(() => enabled ? {
|
|
363
|
+
reference,
|
|
364
|
+
floating,
|
|
365
|
+
trigger: reference
|
|
366
|
+
} : {}, [
|
|
367
|
+
enabled,
|
|
368
|
+
reference,
|
|
369
|
+
floating
|
|
370
|
+
]);
|
|
371
|
+
}
|
|
372
|
+
//#endregion
|
|
373
|
+
export { normalizeProp, useDismiss };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isElement } from "../../../../@floating-ui/utils/dist/floating-ui.utils.dom.js";
|
|
3
|
+
import { useIsoLayoutEffect } from "../../../utils/useIsoLayoutEffect.js";
|
|
4
|
+
import { FloatingRootStore } from "../components/FloatingRootStore.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
|
|
7
|
+
/**
|
|
8
|
+
* Narrowed to the store members this hook uses so consumers do not need to provide
|
|
9
|
+
* unrelated store capabilities.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Keeps a FloatingRootStore in sync with the provided PopupStore.
|
|
13
|
+
* Uses the provided FloatingRootStore when one exists, otherwise creates one once and updates it on every render.
|
|
14
|
+
*/
|
|
15
|
+
function useSyncedFloatingRootContext(options) {
|
|
16
|
+
const { popupStore, treatPopupAsFloatingElement = false, floatingRootContext: floatingRootContextProp, floatingId, nested, onOpenChange } = options;
|
|
17
|
+
const open = popupStore.useState("open");
|
|
18
|
+
const referenceElement = popupStore.useState("activeTriggerElement");
|
|
19
|
+
const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
|
|
20
|
+
const triggerElements = popupStore.context.triggerElements;
|
|
21
|
+
const handleOpenChange = onOpenChange;
|
|
22
|
+
const internalStoreRef = React.useRef(null);
|
|
23
|
+
if (floatingRootContextProp === void 0 && internalStoreRef.current === null) internalStoreRef.current = new FloatingRootStore({
|
|
24
|
+
open,
|
|
25
|
+
transitionStatus: void 0,
|
|
26
|
+
referenceElement,
|
|
27
|
+
floatingElement,
|
|
28
|
+
triggerElements,
|
|
29
|
+
onOpenChange: handleOpenChange,
|
|
30
|
+
floatingId,
|
|
31
|
+
syncOnly: true,
|
|
32
|
+
nested
|
|
33
|
+
});
|
|
34
|
+
const store = floatingRootContextProp ?? internalStoreRef.current;
|
|
35
|
+
popupStore.useSyncedValue("floatingId", floatingId);
|
|
36
|
+
useIsoLayoutEffect(() => {
|
|
37
|
+
const valuesToSync = {
|
|
38
|
+
open,
|
|
39
|
+
floatingId,
|
|
40
|
+
referenceElement,
|
|
41
|
+
floatingElement
|
|
42
|
+
};
|
|
43
|
+
if (isElement(referenceElement)) valuesToSync.domReferenceElement = referenceElement;
|
|
44
|
+
if (store.state.positionReference === store.state.referenceElement) valuesToSync.positionReference = referenceElement;
|
|
45
|
+
store.update(valuesToSync);
|
|
46
|
+
}, [
|
|
47
|
+
open,
|
|
48
|
+
floatingId,
|
|
49
|
+
referenceElement,
|
|
50
|
+
floatingElement,
|
|
51
|
+
store
|
|
52
|
+
]);
|
|
53
|
+
store.context.onOpenChange = handleOpenChange;
|
|
54
|
+
store.context.nested = nested;
|
|
55
|
+
return store;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { useSyncedFloatingRootContext };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getComputedStyle } from "../../../../@floating-ui/utils/dist/floating-ui.utils.dom.js";
|
|
2
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs
|
|
3
|
+
function isIndexOutOfListBounds(list, index) {
|
|
4
|
+
return index < 0 || index >= list.length;
|
|
5
|
+
}
|
|
6
|
+
function getMinListIndex(listRef, disabledIndices) {
|
|
7
|
+
return findNonDisabledListIndex(listRef.current, { disabledIndices });
|
|
8
|
+
}
|
|
9
|
+
function getMaxListIndex(listRef, disabledIndices) {
|
|
10
|
+
return findNonDisabledListIndex(listRef.current, {
|
|
11
|
+
decrement: true,
|
|
12
|
+
startingIndex: listRef.current.length,
|
|
13
|
+
disabledIndices
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function findNonDisabledListIndex(list, { startingIndex = -1, decrement = false, disabledIndices, amount = 1 } = {}) {
|
|
17
|
+
let index = startingIndex;
|
|
18
|
+
do
|
|
19
|
+
index += decrement ? -amount : amount;
|
|
20
|
+
while (index >= 0 && index <= list.length - 1 && isListIndexDisabled(list, index, disabledIndices));
|
|
21
|
+
return index;
|
|
22
|
+
}
|
|
23
|
+
function isListIndexDisabled(list, index, disabledIndices) {
|
|
24
|
+
if (typeof disabledIndices === "function" ? disabledIndices(index) : disabledIndices?.includes(index) ?? false) return true;
|
|
25
|
+
const element = list[index];
|
|
26
|
+
if (!element) return false;
|
|
27
|
+
if (!isElementVisible(element)) return true;
|
|
28
|
+
if (element.matches(":disabled")) return true;
|
|
29
|
+
return !disabledIndices && (element.hasAttribute("disabled") || element.getAttribute("aria-disabled") === "true");
|
|
30
|
+
}
|
|
31
|
+
function isHiddenByStyles(styles) {
|
|
32
|
+
return styles.visibility === "hidden" || styles.visibility === "collapse";
|
|
33
|
+
}
|
|
34
|
+
function isElementVisible(element, styles = element ? getComputedStyle(element) : null) {
|
|
35
|
+
if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) return false;
|
|
36
|
+
if (typeof element.checkVisibility === "function") return element.checkVisibility();
|
|
37
|
+
return styles.display !== "none" && styles.display !== "contents";
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { findNonDisabledListIndex, getMaxListIndex, getMinListIndex, isElementVisible, isHiddenByStyles, isIndexOutOfListBounds, isListIndexDisabled };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs
|
|
2
|
+
const FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
|
|
3
|
+
const TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";
|
|
4
|
+
//#endregion
|
|
5
|
+
export { FOCUSABLE_ATTRIBUTE, TYPEABLE_SELECTOR };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs
|
|
2
|
+
function createAttribute(name) {
|
|
3
|
+
return `data-base-ui-${name}`;
|
|
4
|
+
}
|
|
5
|
+
//#endregion
|
|
6
|
+
export { createAttribute };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs
|
|
2
|
+
function createEventEmitter() {
|
|
3
|
+
const map = /* @__PURE__ */ new Map();
|
|
4
|
+
return {
|
|
5
|
+
emit(event, data) {
|
|
6
|
+
map.get(event)?.forEach((listener) => listener(data));
|
|
7
|
+
},
|
|
8
|
+
on(event, listener) {
|
|
9
|
+
if (!map.has(event)) map.set(event, /* @__PURE__ */ new Set());
|
|
10
|
+
map.get(event).add(listener);
|
|
11
|
+
},
|
|
12
|
+
off(event, listener) {
|
|
13
|
+
map.get(event)?.delete(listener);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { createEventEmitter };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isHTMLElement } from "../../../../@floating-ui/utils/dist/floating-ui.utils.dom.js";
|
|
2
|
+
import { activeElement, contains, getTarget } from "../../../utils/shadowDom.js";
|
|
3
|
+
import "./constants.js";
|
|
4
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/floating-ui-react/utils/element.mjs
|
|
5
|
+
function isEventTargetWithin(event, node) {
|
|
6
|
+
if (node == null) return false;
|
|
7
|
+
if ("composedPath" in event) return event.composedPath().includes(node);
|
|
8
|
+
const eventAgain = event;
|
|
9
|
+
return eventAgain.target != null && node.contains(eventAgain.target);
|
|
10
|
+
}
|
|
11
|
+
function isRootElement(element) {
|
|
12
|
+
return element.matches("html,body");
|
|
13
|
+
}
|
|
14
|
+
function isTypeableElement(element) {
|
|
15
|
+
return isHTMLElement(element) && element.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])");
|
|
16
|
+
}
|
|
17
|
+
function isTypeableCombobox(element) {
|
|
18
|
+
if (!element) return false;
|
|
19
|
+
return element.getAttribute("role") === "combobox" && isTypeableElement(element);
|
|
20
|
+
}
|
|
21
|
+
function getFloatingFocusElement(floatingElement) {
|
|
22
|
+
if (!floatingElement) return null;
|
|
23
|
+
return floatingElement.hasAttribute("data-base-ui-focusable") ? floatingElement : floatingElement.querySelector(`[data-base-ui-focusable]`) || floatingElement;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { activeElement, contains, getFloatingFocusElement, getTarget, isEventTargetWithin, isRootElement, isTypeableCombobox, isTypeableElement };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NOOP } from "../../../utils/empty.js";
|
|
2
|
+
//#region ../../../node_modules/.pnpm/@base-ui+react@1.8.0_@date-fns+tz@1.5.0_@types+react@19.3.0_date-fns@4.4.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/react/floating-ui-react/utils/enqueueFocus.mjs
|
|
3
|
+
let rafId = 0;
|
|
4
|
+
function enqueueFocus(el, options = {}) {
|
|
5
|
+
const { preventScroll = false, sync = false, shouldFocus } = options;
|
|
6
|
+
cancelAnimationFrame(rafId);
|
|
7
|
+
function exec() {
|
|
8
|
+
if (shouldFocus && !shouldFocus()) return;
|
|
9
|
+
el?.focus({ preventScroll });
|
|
10
|
+
}
|
|
11
|
+
if (sync) {
|
|
12
|
+
exec();
|
|
13
|
+
return NOOP;
|
|
14
|
+
}
|
|
15
|
+
const currentRafId = requestAnimationFrame(exec);
|
|
16
|
+
rafId = currentRafId;
|
|
17
|
+
return () => {
|
|
18
|
+
if (rafId === currentRafId) {
|
|
19
|
+
cancelAnimationFrame(currentRafId);
|
|
20
|
+
rafId = 0;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { enqueueFocus };
|