@monimesl/dot-renderer-react 0.1.0-alpha.8 → 0.1.0-alpha.9
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 +39 -1
- package/dist/LICENSE-PHOSPHOR +21 -21
- 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 -64
- package/dist/index.js +32 -22636
- package/dist/page-root.d.ts +2 -0
- package/dist/page-root.js +20 -0
- package/dist/portal.js +8 -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 -1
- 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 +8 -14
- package/dist/garra-versions.json +0 -7
|
@@ -0,0 +1,12 @@
|
|
|
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/internals/serializeValue.mjs
|
|
2
|
+
function serializeValue(value) {
|
|
3
|
+
if (value == null) return "";
|
|
4
|
+
if (typeof value === "string") return value;
|
|
5
|
+
try {
|
|
6
|
+
return JSON.stringify(value);
|
|
7
|
+
} catch {
|
|
8
|
+
return String(value);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { serializeValue };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { endingStyle, startingStyle } from "./TransitionStatusDataAttributes.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/internals/stateAttributesMapping.mjs
|
|
3
|
+
const STARTING_HOOK = { [startingStyle]: "" };
|
|
4
|
+
const ENDING_HOOK = { [endingStyle]: "" };
|
|
5
|
+
const transitionStatusMapping = { transitionStatus(value) {
|
|
6
|
+
if (value === "starting") return STARTING_HOOK;
|
|
7
|
+
if (value === "ending") return ENDING_HOOK;
|
|
8
|
+
return null;
|
|
9
|
+
} };
|
|
10
|
+
//#endregion
|
|
11
|
+
export { transitionStatusMapping };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { makeEventPreventable, mergeProps } from "../../merge-props/mergeProps.js";
|
|
3
|
+
import { isHTMLElement } from "../../../../@floating-ui/utils/dist/floating-ui.utils.dom.js";
|
|
4
|
+
import { SafeReact } from "../../../utils/safeReact.js";
|
|
5
|
+
import { useStableCallback } from "../../../utils/useStableCallback.js";
|
|
6
|
+
import { error } from "../../../utils/error.js";
|
|
7
|
+
import { useIsoLayoutEffect } from "../../../utils/useIsoLayoutEffect.js";
|
|
8
|
+
import { useCompositeRootContext } from "../composite/root/CompositeRootContext.js";
|
|
9
|
+
import { useFocusableWhenDisabled } from "../../utils/useFocusableWhenDisabled.js";
|
|
10
|
+
import { dispatchClickWithModifiers } from "../../utils/dispatchClickWithModifiers.js";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
//#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/internals/use-button/useButton.mjs
|
|
13
|
+
function useButton(parameters = {}) {
|
|
14
|
+
const { disabled = false, focusableWhenDisabled, tabIndex = 0, native: isNativeButton = true, composite: compositeProp } = parameters;
|
|
15
|
+
const elementRef = React.useRef(null);
|
|
16
|
+
const compositeRootContext = useCompositeRootContext(true);
|
|
17
|
+
const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
|
|
18
|
+
const { props: focusableWhenDisabledProps } = useFocusableWhenDisabled({
|
|
19
|
+
focusableWhenDisabled,
|
|
20
|
+
disabled,
|
|
21
|
+
composite: isCompositeItem,
|
|
22
|
+
tabIndex,
|
|
23
|
+
isNativeButton
|
|
24
|
+
});
|
|
25
|
+
if (process.env.NODE_ENV !== "production") React.useEffect(() => {
|
|
26
|
+
if (!elementRef.current) return;
|
|
27
|
+
const isButtonTag = isButtonElement(elementRef.current);
|
|
28
|
+
if (isNativeButton) {
|
|
29
|
+
if (!isButtonTag) {
|
|
30
|
+
const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
|
|
31
|
+
error(`A component that acts as a button expected a native <button> because the \`nativeButton\` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the \`render\` prop, or set \`nativeButton\` to \`false\`.${ownerStackMessage}`);
|
|
32
|
+
}
|
|
33
|
+
} else if (isButtonTag) {
|
|
34
|
+
const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
|
|
35
|
+
error(`A component that acts as a button expected a non-<button> because the \`nativeButton\` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as \`role\` or \`aria-disabled\`). Use a non-<button> in the \`render\` prop, or set \`nativeButton\` to \`true\`.${ownerStackMessage}`);
|
|
36
|
+
}
|
|
37
|
+
}, [isNativeButton]);
|
|
38
|
+
const updateDisabled = React.useCallback(() => {
|
|
39
|
+
const element = elementRef.current;
|
|
40
|
+
if (!isButtonElement(element)) return;
|
|
41
|
+
if (isCompositeItem && disabled && focusableWhenDisabledProps.disabled === void 0 && element.disabled) element.disabled = false;
|
|
42
|
+
}, [
|
|
43
|
+
disabled,
|
|
44
|
+
focusableWhenDisabledProps.disabled,
|
|
45
|
+
isCompositeItem
|
|
46
|
+
]);
|
|
47
|
+
useIsoLayoutEffect(updateDisabled, [updateDisabled]);
|
|
48
|
+
return {
|
|
49
|
+
getButtonProps: React.useCallback((externalProps = {}) => {
|
|
50
|
+
const { onClick: externalOnClick, onMouseDown: externalOnMouseDown, onKeyUp: externalOnKeyUp, onKeyDown: externalOnKeyDown, onPointerDown: externalOnPointerDown, ...otherExternalProps } = externalProps;
|
|
51
|
+
return mergeProps({
|
|
52
|
+
onClick(event) {
|
|
53
|
+
if (disabled) {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
externalOnClick?.(event);
|
|
58
|
+
},
|
|
59
|
+
onMouseDown(event) {
|
|
60
|
+
if (!disabled) externalOnMouseDown?.(event);
|
|
61
|
+
},
|
|
62
|
+
onKeyDown(event) {
|
|
63
|
+
if (disabled) return;
|
|
64
|
+
makeEventPreventable(event);
|
|
65
|
+
externalOnKeyDown?.(event);
|
|
66
|
+
if (event.baseUIHandlerPrevented) return;
|
|
67
|
+
const isCurrentTarget = event.target === event.currentTarget;
|
|
68
|
+
const currentTarget = event.currentTarget;
|
|
69
|
+
const isButton = isButtonElement(currentTarget);
|
|
70
|
+
const isLink = !isNativeButton && isValidLinkElement(currentTarget);
|
|
71
|
+
const shouldClick = isCurrentTarget && (isNativeButton ? isButton : !isLink);
|
|
72
|
+
const isEnterKey = event.key === "Enter";
|
|
73
|
+
const isSpaceKey = event.key === " ";
|
|
74
|
+
const role = currentTarget.getAttribute("role");
|
|
75
|
+
const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
|
|
76
|
+
if (isCurrentTarget && isCompositeItem && isSpaceKey) {
|
|
77
|
+
if (event.defaultPrevented && isTextNavigationRole) return;
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
if (!isNativeButton || isButton) {
|
|
80
|
+
event.preventBaseUIHandler();
|
|
81
|
+
dispatchClickWithModifiers(currentTarget, event);
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!shouldClick || isNativeButton || !isSpaceKey && !isEnterKey) {
|
|
86
|
+
if (isCurrentTarget && isLink && isSpaceKey) event.preventDefault();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (event.defaultPrevented) return;
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
if (isEnterKey) {
|
|
92
|
+
event.preventBaseUIHandler();
|
|
93
|
+
dispatchClickWithModifiers(currentTarget, event);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
onKeyUp(event) {
|
|
97
|
+
if (disabled) return;
|
|
98
|
+
makeEventPreventable(event);
|
|
99
|
+
externalOnKeyUp?.(event);
|
|
100
|
+
if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (event.baseUIHandlerPrevented) return;
|
|
105
|
+
if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && !event.defaultPrevented && event.key === " ") {
|
|
106
|
+
event.preventBaseUIHandler();
|
|
107
|
+
dispatchClickWithModifiers(event.currentTarget, event);
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
onPointerDown(event) {
|
|
111
|
+
if (disabled) {
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
externalOnPointerDown?.(event);
|
|
116
|
+
}
|
|
117
|
+
}, isNativeButton ? { type: "button" } : { role: "button" }, focusableWhenDisabledProps, otherExternalProps);
|
|
118
|
+
}, [
|
|
119
|
+
disabled,
|
|
120
|
+
focusableWhenDisabledProps,
|
|
121
|
+
isCompositeItem,
|
|
122
|
+
isNativeButton
|
|
123
|
+
]),
|
|
124
|
+
buttonRef: useStableCallback((element) => {
|
|
125
|
+
elementRef.current = element;
|
|
126
|
+
updateDisabled();
|
|
127
|
+
})
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function isButtonElement(elem) {
|
|
131
|
+
return isHTMLElement(elem) && elem.tagName === "BUTTON";
|
|
132
|
+
}
|
|
133
|
+
function isValidLinkElement(elem) {
|
|
134
|
+
return isHTMLElement(elem) && elem.tagName === "A" && Boolean(elem.href);
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
export { useButton };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { startingStyle } from "./TransitionStatusDataAttributes.js";
|
|
3
|
+
import { useStableCallback } from "../../utils/useStableCallback.js";
|
|
4
|
+
import { useAnimationFrame } from "../../utils/useAnimationFrame.js";
|
|
5
|
+
import { resolveRef } from "../utils/resolveRef.js";
|
|
6
|
+
import * as ReactDOM from "react-dom";
|
|
7
|
+
//#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/internals/useAnimationsFinished.mjs
|
|
8
|
+
let pendingCallbacks = null;
|
|
9
|
+
/**
|
|
10
|
+
* Runs the callback in a synchronous flush before the browser paints, so that the
|
|
11
|
+
* browser doesn't paint an intermediate frame: https://github.com/mui/base-ui/issues/979
|
|
12
|
+
* Callbacks that become ready within the same microtask checkpoint (e.g. multiple elements
|
|
13
|
+
* whose animations finish together) are batched into a single commit:
|
|
14
|
+
* https://github.com/mui/base-ui/issues/5481
|
|
15
|
+
*/
|
|
16
|
+
function flushBeforePaint(fn) {
|
|
17
|
+
if (!pendingCallbacks) {
|
|
18
|
+
const callbacks = [];
|
|
19
|
+
pendingCallbacks = callbacks;
|
|
20
|
+
queueMicrotask(() => {
|
|
21
|
+
pendingCallbacks = null;
|
|
22
|
+
ReactDOM.flushSync(() => {
|
|
23
|
+
for (const callback of callbacks) callback();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
pendingCallbacks.push(fn);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Executes a function once all animations have finished on the provided element.
|
|
31
|
+
* If an animation is canceled, waits for any replacement animations before executing.
|
|
32
|
+
* @param elementOrRef - The element to watch for animations.
|
|
33
|
+
* @param waitForStartingStyleRemoved - Whether to wait for [data-starting-style] to be removed before checking for animations.
|
|
34
|
+
* @param batch - Whether completions ready in the same microtask may be coalesced into a single
|
|
35
|
+
* commit. A batched callback runs before earlier callbacks' React updates have committed, so only
|
|
36
|
+
* opt in when the callback doesn't read state that another completion can change.
|
|
37
|
+
* @returns A function that takes a callback to execute once all animations have finished, and an optional AbortSignal to abort the callback
|
|
38
|
+
*/
|
|
39
|
+
function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, batch = false) {
|
|
40
|
+
const frame = useAnimationFrame();
|
|
41
|
+
return useStableCallback((fnToExecute, signal = null) => {
|
|
42
|
+
frame.cancel();
|
|
43
|
+
const element = resolveRef(elementOrRef);
|
|
44
|
+
if (element == null) return;
|
|
45
|
+
const resolvedElement = element;
|
|
46
|
+
const done = () => {
|
|
47
|
+
if (!batch) {
|
|
48
|
+
ReactDOM.flushSync(fnToExecute);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
flushBeforePaint(() => {
|
|
52
|
+
if (!signal?.aborted) fnToExecute();
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
|
|
56
|
+
fnToExecute();
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
function exec() {
|
|
60
|
+
Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
|
|
61
|
+
if (!signal?.aborted) done();
|
|
62
|
+
}, () => {
|
|
63
|
+
if (signal?.aborted) return;
|
|
64
|
+
if (resolvedElement.getAnimations().some((animation) => animation.pending || animation.playState !== "finished")) {
|
|
65
|
+
exec();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
done();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (waitForStartingStyleRemoved) {
|
|
72
|
+
const startingStyleAttribute = startingStyle;
|
|
73
|
+
if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
|
|
74
|
+
frame.request(exec);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const attributeObserver = new MutationObserver(() => {
|
|
78
|
+
if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
|
|
79
|
+
attributeObserver.disconnect();
|
|
80
|
+
exec();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
attributeObserver.observe(resolvedElement, {
|
|
84
|
+
attributes: true,
|
|
85
|
+
attributeFilter: [startingStyleAttribute]
|
|
86
|
+
});
|
|
87
|
+
signal?.addEventListener("abort", () => attributeObserver.disconnect(), { once: true });
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
frame.request(exec);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
export { useAnimationsFinished };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useId } from "../../utils/useId.js";
|
|
3
|
+
//#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/internals/useBaseUiId.mjs
|
|
4
|
+
/**
|
|
5
|
+
* Wraps `useId` and prefixes generated `id`s with `base-ui-`
|
|
6
|
+
* @param {string | undefined} idOverride overrides the generated id when provided
|
|
7
|
+
* @returns {string | undefined}
|
|
8
|
+
*/
|
|
9
|
+
function useBaseUiId(idOverride) {
|
|
10
|
+
return useId(idOverride, "base-ui");
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { useBaseUiId };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useStableCallback } from "../../utils/useStableCallback.js";
|
|
3
|
+
import { useAnimationsFinished } from "./useAnimationsFinished.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
//#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/internals/useOpenChangeComplete.mjs
|
|
6
|
+
/**
|
|
7
|
+
* Calls the provided function when the CSS open/close animation or transition completes.
|
|
8
|
+
*/
|
|
9
|
+
function useOpenChangeComplete(parameters) {
|
|
10
|
+
const { enabled = true, open, ref, batch = false, onComplete: onCompleteParam } = parameters;
|
|
11
|
+
const onComplete = useStableCallback(onCompleteParam);
|
|
12
|
+
const runOnceAnimationsFinish = useAnimationsFinished(ref, open, batch);
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
if (!enabled) return;
|
|
15
|
+
const abortController = new AbortController();
|
|
16
|
+
runOnceAnimationsFinish(onComplete, abortController.signal);
|
|
17
|
+
return () => {
|
|
18
|
+
abortController.abort();
|
|
19
|
+
};
|
|
20
|
+
}, [
|
|
21
|
+
enabled,
|
|
22
|
+
open,
|
|
23
|
+
onComplete,
|
|
24
|
+
runOnceAnimationsFinish
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { useOpenChangeComplete };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import formatErrorMessage from "../../utils/formatErrorMessage.js";
|
|
2
|
+
import { useMergedRefs, useMergedRefsN } from "../../utils/useMergedRefs.js";
|
|
3
|
+
import { getReactElementRef } from "../../utils/getReactElementRef.js";
|
|
4
|
+
import { mergeObjects } from "../../utils/mergeObjects.js";
|
|
5
|
+
import { warn } from "../../utils/warn.js";
|
|
6
|
+
import { EMPTY_OBJECT } from "../../utils/empty.js";
|
|
7
|
+
import { getStateAttributesProps } from "./getStateAttributesProps.js";
|
|
8
|
+
import { resolveClassName } from "../utils/resolveClassName.js";
|
|
9
|
+
import { resolveStyle } from "../utils/resolveStyle.js";
|
|
10
|
+
import { mergeClassNames, mergeProps, mergePropsN } from "../merge-props/mergeProps.js";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import { createElement } from "react";
|
|
13
|
+
//#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/internals/useRenderElement.mjs
|
|
14
|
+
/**
|
|
15
|
+
* Renders a Base UI element.
|
|
16
|
+
*
|
|
17
|
+
* @param element The default HTML element to render. Can be overridden by the `render` prop.
|
|
18
|
+
* @param componentProps An object containing the `render` and `className` props to be used for element customization. Other props are ignored.
|
|
19
|
+
* @param params Additional parameters for rendering the element.
|
|
20
|
+
*/
|
|
21
|
+
function useRenderElement(element, componentProps, params = {}) {
|
|
22
|
+
let renderProp = componentProps.render;
|
|
23
|
+
if (params.enabled !== false) renderProp = unwrapLazyRenderProp(renderProp);
|
|
24
|
+
const outProps = useRenderElementProps(componentProps, params, renderProp);
|
|
25
|
+
if (params.enabled === false) return null;
|
|
26
|
+
const state = params.state ?? EMPTY_OBJECT;
|
|
27
|
+
return evaluateRenderProp(element, renderProp, outProps, state);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Computes render element final props.
|
|
31
|
+
*/
|
|
32
|
+
function useRenderElementProps(componentProps, params, renderProp) {
|
|
33
|
+
const { className: classNameProp, style: styleProp } = componentProps;
|
|
34
|
+
const { state = EMPTY_OBJECT, ref, props, stateAttributesMapping, enabled = true } = params;
|
|
35
|
+
const className = enabled ? resolveClassName(classNameProp, state) : void 0;
|
|
36
|
+
const style = enabled ? resolveStyle(styleProp, state) : void 0;
|
|
37
|
+
const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
|
|
38
|
+
const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
|
|
39
|
+
const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
|
|
40
|
+
if (typeof document !== "undefined") {
|
|
41
|
+
if (!enabled) useMergedRefs(null, null);
|
|
42
|
+
else if (Array.isArray(ref)) outProps.ref = useMergedRefsN([
|
|
43
|
+
outProps.ref,
|
|
44
|
+
getReactElementRef(renderProp),
|
|
45
|
+
...ref
|
|
46
|
+
]);
|
|
47
|
+
else outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
|
|
48
|
+
}
|
|
49
|
+
if (!enabled) return EMPTY_OBJECT;
|
|
50
|
+
if (className !== void 0) outProps.className = mergeClassNames(outProps.className, className);
|
|
51
|
+
if (style !== void 0) outProps.style = mergeObjects(outProps.style, style);
|
|
52
|
+
return outProps;
|
|
53
|
+
}
|
|
54
|
+
function resolveRenderFunctionProps(props) {
|
|
55
|
+
if (Array.isArray(props)) return mergePropsN(props);
|
|
56
|
+
return mergeProps(void 0, props);
|
|
57
|
+
}
|
|
58
|
+
const REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
59
|
+
const COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
|
|
60
|
+
const LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
|
|
61
|
+
function unwrapLazyRenderProp(render) {
|
|
62
|
+
if (render?.$$typeof !== REACT_LAZY_TYPE) return render;
|
|
63
|
+
const unwrapped = React.Children.toArray(render)[0];
|
|
64
|
+
return /*#__PURE__*/ React.isValidElement(unwrapped) ? unwrapped : render;
|
|
65
|
+
}
|
|
66
|
+
function evaluateRenderProp(element, render, props, state) {
|
|
67
|
+
if (render) {
|
|
68
|
+
if (typeof render === "function") {
|
|
69
|
+
if (process.env.NODE_ENV !== "production") warnIfRenderPropLooksLikeComponent(render);
|
|
70
|
+
return render(props, state);
|
|
71
|
+
}
|
|
72
|
+
const mergedProps = mergeProps(props, render.props);
|
|
73
|
+
mergedProps.ref = props.ref;
|
|
74
|
+
if (process.env.NODE_ENV !== "production") {
|
|
75
|
+
if (!/*#__PURE__*/ React.isValidElement(render)) throw new Error([
|
|
76
|
+
"Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.",
|
|
77
|
+
"A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.",
|
|
78
|
+
"https://base-ui.com/r/invalid-render-prop"
|
|
79
|
+
].join("\n"));
|
|
80
|
+
}
|
|
81
|
+
return /*#__PURE__*/ React.cloneElement(render, mergedProps);
|
|
82
|
+
}
|
|
83
|
+
if (element) {
|
|
84
|
+
if (typeof element === "string") return renderTag(element, props);
|
|
85
|
+
}
|
|
86
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: Render element or function are not defined." : formatErrorMessage(8));
|
|
87
|
+
}
|
|
88
|
+
function warnIfRenderPropLooksLikeComponent(renderFn) {
|
|
89
|
+
const functionName = renderFn.name;
|
|
90
|
+
if (functionName.length === 0) return;
|
|
91
|
+
if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) return;
|
|
92
|
+
if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) return;
|
|
93
|
+
warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
|
|
94
|
+
}
|
|
95
|
+
function renderTag(Tag, props) {
|
|
96
|
+
if (Tag === "button") return /*#__PURE__*/ createElement("button", {
|
|
97
|
+
type: "button",
|
|
98
|
+
...props,
|
|
99
|
+
key: props.key
|
|
100
|
+
});
|
|
101
|
+
if (Tag === "img") return /*#__PURE__*/ createElement("img", {
|
|
102
|
+
alt: "",
|
|
103
|
+
...props,
|
|
104
|
+
key: props.key
|
|
105
|
+
});
|
|
106
|
+
return /*#__PURE__*/ React.createElement(Tag, props);
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { useRenderElement };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useIsoLayoutEffect } from "../../utils/useIsoLayoutEffect.js";
|
|
3
|
+
import { AnimationFrame } from "../../utils/useAnimationFrame.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
//#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/internals/useTransitionStatus.mjs
|
|
6
|
+
/**
|
|
7
|
+
* Provides a status string for CSS animations.
|
|
8
|
+
* @param open - a boolean that determines if the element is open.
|
|
9
|
+
* @param enableIdleState - a boolean that enables the `'idle'` state between `'starting'` and `'ending'`
|
|
10
|
+
* @param deferEndingState - a boolean that delays the `'ending'` state by a frame
|
|
11
|
+
* @param animateInitialOpen - a boolean that makes an element which mounts already open still go
|
|
12
|
+
* through `'starting'`. Off by default so content that was open on the first render (a
|
|
13
|
+
* `defaultOpen` popup on page load, SSR'd markup) doesn't animate in.
|
|
14
|
+
*/
|
|
15
|
+
function useTransitionStatus(open, enableIdleState = false, deferEndingState = false, animateInitialOpen = false) {
|
|
16
|
+
const [transitionStatus, setTransitionStatus] = React.useState(open && enableIdleState ? "idle" : void 0);
|
|
17
|
+
const [mounted, setMounted] = React.useState(open && !animateInitialOpen);
|
|
18
|
+
if (open && !mounted) {
|
|
19
|
+
setMounted(true);
|
|
20
|
+
setTransitionStatus("starting");
|
|
21
|
+
}
|
|
22
|
+
if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) setTransitionStatus("ending");
|
|
23
|
+
if (!open && !mounted && transitionStatus === "ending") setTransitionStatus(void 0);
|
|
24
|
+
useIsoLayoutEffect(() => {
|
|
25
|
+
if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
|
|
26
|
+
const frame = AnimationFrame.request(() => {
|
|
27
|
+
setTransitionStatus("ending");
|
|
28
|
+
});
|
|
29
|
+
return () => {
|
|
30
|
+
AnimationFrame.cancel(frame);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}, [
|
|
34
|
+
open,
|
|
35
|
+
mounted,
|
|
36
|
+
transitionStatus,
|
|
37
|
+
deferEndingState
|
|
38
|
+
]);
|
|
39
|
+
useIsoLayoutEffect(() => {
|
|
40
|
+
if (!open || enableIdleState) return;
|
|
41
|
+
const frame = AnimationFrame.request(() => {
|
|
42
|
+
setTransitionStatus(void 0);
|
|
43
|
+
});
|
|
44
|
+
return () => {
|
|
45
|
+
AnimationFrame.cancel(frame);
|
|
46
|
+
};
|
|
47
|
+
}, [enableIdleState, open]);
|
|
48
|
+
useIsoLayoutEffect(() => {
|
|
49
|
+
if (!open || !enableIdleState) return;
|
|
50
|
+
if (open && mounted && transitionStatus !== "idle") setTransitionStatus("starting");
|
|
51
|
+
const frame = AnimationFrame.request(() => {
|
|
52
|
+
setTransitionStatus("idle");
|
|
53
|
+
});
|
|
54
|
+
return () => {
|
|
55
|
+
AnimationFrame.cancel(frame);
|
|
56
|
+
};
|
|
57
|
+
}, [
|
|
58
|
+
enableIdleState,
|
|
59
|
+
open,
|
|
60
|
+
mounted,
|
|
61
|
+
transitionStatus
|
|
62
|
+
]);
|
|
63
|
+
return {
|
|
64
|
+
mounted,
|
|
65
|
+
setMounted,
|
|
66
|
+
transitionStatus
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { useTransitionStatus };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useStableCallback } from "../../utils/useStableCallback.js";
|
|
3
|
+
import { useIsoLayoutEffect } from "../../utils/useIsoLayoutEffect.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
//#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/internals/useValueChanged.mjs
|
|
6
|
+
function useValueChanged(value, onChange) {
|
|
7
|
+
const valueRef = React.useRef(value);
|
|
8
|
+
const onChangeCallback = useStableCallback(onChange);
|
|
9
|
+
useIsoLayoutEffect(() => {
|
|
10
|
+
if (valueRef.current !== value) onChangeCallback(valueRef.current);
|
|
11
|
+
valueRef.current = value;
|
|
12
|
+
}, [value, onChangeCallback]);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useValueChanged };
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { mergeObjects } from "../../utils/mergeObjects.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/merge-props/mergeProps.mjs
|
|
3
|
+
const EMPTY_PROPS = {};
|
|
4
|
+
/**
|
|
5
|
+
* Merges multiple sets of React props. It follows the Object.assign pattern where the rightmost object's fields overwrite
|
|
6
|
+
* the conflicting ones from others. This doesn't apply to event handlers, `className` and `style` props.
|
|
7
|
+
*
|
|
8
|
+
* Event handlers are merged and called in right-to-left order (rightmost handler executes first, leftmost last).
|
|
9
|
+
* For React synthetic events, the rightmost handler can prevent prior (left-positioned) handlers from executing
|
|
10
|
+
* by calling `event.preventBaseUIHandler()`. For non-synthetic events (custom events with primitive/object values),
|
|
11
|
+
* all handlers always execute without prevention capability.
|
|
12
|
+
*
|
|
13
|
+
* The `className` prop is merged by concatenating classes in right-to-left order (rightmost class appears first in the string).
|
|
14
|
+
* The `style` prop is merged with rightmost styles overwriting the prior ones.
|
|
15
|
+
*
|
|
16
|
+
* Props can either be provided as objects or as functions that take the previous props as an argument.
|
|
17
|
+
* The function will receive the merged props up to that point (going from left to right):
|
|
18
|
+
* so in the case of `(obj1, obj2, fn, obj3)`, `fn` will receive the merged props of `obj1` and `obj2`.
|
|
19
|
+
* The function is responsible for chaining event handlers if needed (that is, we don't run the merge logic).
|
|
20
|
+
*
|
|
21
|
+
* Event handlers returned by the functions are not automatically prevented when `preventBaseUIHandler` is called.
|
|
22
|
+
* They must check `event.baseUIHandlerPrevented` themselves and bail out if it's true.
|
|
23
|
+
*
|
|
24
|
+
* @important **`ref` is not merged.**
|
|
25
|
+
* @param a Props object to merge.
|
|
26
|
+
* @param b Props object to merge. The function will overwrite conflicting props from `a`.
|
|
27
|
+
* @param c Props object to merge. The function will overwrite conflicting props from previous parameters.
|
|
28
|
+
* @param d Props object to merge. The function will overwrite conflicting props from previous parameters.
|
|
29
|
+
* @param e Props object to merge. The function will overwrite conflicting props from previous parameters.
|
|
30
|
+
* @returns The merged props.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
function mergeProps(a, b, c, d, e) {
|
|
34
|
+
if (!c && !d && !e && !a) return createInitialMergedProps(b);
|
|
35
|
+
let merged = createInitialMergedProps(a);
|
|
36
|
+
if (b) merged = mergeInto(merged, b);
|
|
37
|
+
if (c) merged = mergeInto(merged, c);
|
|
38
|
+
if (d) merged = mergeInto(merged, d);
|
|
39
|
+
if (e) merged = mergeInto(merged, e);
|
|
40
|
+
return merged;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Merges an arbitrary number of React props using the same logic as {@link mergeProps}.
|
|
44
|
+
* This function accepts an array of props instead of individual arguments.
|
|
45
|
+
*
|
|
46
|
+
* This has slightly lower performance than {@link mergeProps} due to accepting an array
|
|
47
|
+
* instead of a fixed number of arguments. Prefer {@link mergeProps} when merging 5 or
|
|
48
|
+
* fewer prop sets for better performance.
|
|
49
|
+
*
|
|
50
|
+
* @param props Array of props to merge.
|
|
51
|
+
* @returns The merged props.
|
|
52
|
+
* @see mergeProps
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
function mergePropsN(props) {
|
|
56
|
+
if (props.length === 0) return EMPTY_PROPS;
|
|
57
|
+
if (props.length === 1) return createInitialMergedProps(props[0]);
|
|
58
|
+
let merged = createInitialMergedProps(props[0]);
|
|
59
|
+
for (let i = 1; i < props.length; i += 1) merged = mergeInto(merged, props[i]);
|
|
60
|
+
return merged;
|
|
61
|
+
}
|
|
62
|
+
function createInitialMergedProps(inputProps) {
|
|
63
|
+
if (isPropsGetter(inputProps)) return { ...resolvePropsGetter(inputProps, EMPTY_PROPS) };
|
|
64
|
+
return copyInitialProps(inputProps);
|
|
65
|
+
}
|
|
66
|
+
function mergeInto(merged, inputProps) {
|
|
67
|
+
if (isPropsGetter(inputProps)) return resolvePropsGetter(inputProps, merged);
|
|
68
|
+
return mutablyMergeInto(merged, inputProps);
|
|
69
|
+
}
|
|
70
|
+
function copyInitialProps(inputProps) {
|
|
71
|
+
const copiedProps = { ...inputProps };
|
|
72
|
+
for (const propName in copiedProps) {
|
|
73
|
+
const propValue = copiedProps[propName];
|
|
74
|
+
if (isEventHandler(propName, propValue)) copiedProps[propName] = wrapEventHandler(propValue);
|
|
75
|
+
}
|
|
76
|
+
return copiedProps;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Merges two sets of props. In case of conflicts, the external props take precedence.
|
|
80
|
+
*/
|
|
81
|
+
function mutablyMergeInto(mergedProps, externalProps) {
|
|
82
|
+
if (!externalProps) return mergedProps;
|
|
83
|
+
for (const propName in externalProps) {
|
|
84
|
+
const externalPropValue = externalProps[propName];
|
|
85
|
+
switch (propName) {
|
|
86
|
+
case "style":
|
|
87
|
+
mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
|
|
88
|
+
break;
|
|
89
|
+
case "className":
|
|
90
|
+
mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
|
|
91
|
+
break;
|
|
92
|
+
default: if (isEventHandler(propName, externalPropValue)) mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
|
|
93
|
+
else mergedProps[propName] = externalPropValue;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return mergedProps;
|
|
97
|
+
}
|
|
98
|
+
function isEventHandler(key, value) {
|
|
99
|
+
const code0 = key.charCodeAt(0);
|
|
100
|
+
const code1 = key.charCodeAt(1);
|
|
101
|
+
const code2 = key.charCodeAt(2);
|
|
102
|
+
return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
|
|
103
|
+
}
|
|
104
|
+
function isPropsGetter(inputProps) {
|
|
105
|
+
return typeof inputProps === "function";
|
|
106
|
+
}
|
|
107
|
+
function resolvePropsGetter(inputProps, previousProps) {
|
|
108
|
+
if (isPropsGetter(inputProps)) return inputProps(previousProps);
|
|
109
|
+
return inputProps ?? EMPTY_PROPS;
|
|
110
|
+
}
|
|
111
|
+
function mergeEventHandlers(ourHandler, theirHandler) {
|
|
112
|
+
if (!theirHandler) return ourHandler;
|
|
113
|
+
if (!ourHandler) return wrapEventHandler(theirHandler);
|
|
114
|
+
return (...args) => {
|
|
115
|
+
const event = args[0];
|
|
116
|
+
if (isSyntheticEvent(event)) {
|
|
117
|
+
const baseUIEvent = event;
|
|
118
|
+
makeEventPreventable(baseUIEvent);
|
|
119
|
+
const result = theirHandler(...args);
|
|
120
|
+
if (!baseUIEvent.baseUIHandlerPrevented) ourHandler?.(...args);
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
const result = theirHandler(...args);
|
|
124
|
+
ourHandler?.(...args);
|
|
125
|
+
return result;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function wrapEventHandler(handler) {
|
|
129
|
+
if (!handler) return handler;
|
|
130
|
+
return (...args) => {
|
|
131
|
+
const event = args[0];
|
|
132
|
+
if (isSyntheticEvent(event)) makeEventPreventable(event);
|
|
133
|
+
return handler(...args);
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function makeEventPreventable(event) {
|
|
137
|
+
event.preventBaseUIHandler = () => {
|
|
138
|
+
event.baseUIHandlerPrevented = true;
|
|
139
|
+
};
|
|
140
|
+
return event;
|
|
141
|
+
}
|
|
142
|
+
function mergeClassNames(ourClassName, theirClassName) {
|
|
143
|
+
if (theirClassName) {
|
|
144
|
+
if (ourClassName) return theirClassName + " " + ourClassName;
|
|
145
|
+
return theirClassName;
|
|
146
|
+
}
|
|
147
|
+
return ourClassName;
|
|
148
|
+
}
|
|
149
|
+
function isSyntheticEvent(event) {
|
|
150
|
+
return event != null && typeof event === "object" && "nativeEvent" in event;
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
export { makeEventPreventable, mergeClassNames, mergeProps, mergePropsN };
|