@monimesl/dot-renderer-react 0.1.0-alpha.7 → 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.
Files changed (240) hide show
  1. package/README.md +39 -1
  2. package/dist/LICENSE-PHOSPHOR +21 -21
  3. package/dist/_virtual/_rolldown/runtime.js +14 -0
  4. package/dist/_virtual/builtin_esm-external-require-react.js +9 -0
  5. package/dist/color.js +105 -0
  6. package/dist/components/amount-input.d.ts +6 -0
  7. package/dist/components/amount-input.js +106 -0
  8. package/dist/components/button.d.ts +6 -0
  9. package/dist/components/button.js +42 -0
  10. package/dist/components/carousel.d.ts +6 -0
  11. package/dist/components/carousel.js +254 -0
  12. package/dist/components/chip.d.ts +6 -0
  13. package/dist/components/chip.js +41 -0
  14. package/dist/components/code-input.d.ts +6 -0
  15. package/dist/components/code-input.js +97 -0
  16. package/dist/components/detail-row.d.ts +6 -0
  17. package/dist/components/detail-row.js +40 -0
  18. package/dist/components/divider.d.ts +6 -0
  19. package/dist/components/divider.js +18 -0
  20. package/dist/components/empty-state.d.ts +6 -0
  21. package/dist/components/empty-state.js +66 -0
  22. package/dist/components/feedback.d.ts +8 -0
  23. package/dist/components/feedback.js +85 -0
  24. package/dist/components/field-box.js +44 -0
  25. package/dist/components/field.js +43 -0
  26. package/dist/components/footer.d.ts +6 -0
  27. package/dist/components/footer.js +24 -0
  28. package/dist/components/grid.d.ts +7 -0
  29. package/dist/components/grid.js +98 -0
  30. package/dist/components/icon-artwork.js +74 -0
  31. package/dist/components/icon.d.ts +6 -0
  32. package/dist/components/icon.js +40 -0
  33. package/dist/components/image.d.ts +6 -0
  34. package/dist/components/image.js +40 -0
  35. package/dist/components/index.d.ts +30 -0
  36. package/dist/components/index.js +72 -0
  37. package/dist/components/input.d.ts +6 -0
  38. package/dist/components/input.js +86 -0
  39. package/dist/components/link.d.ts +6 -0
  40. package/dist/components/link.js +39 -0
  41. package/dist/components/list.d.ts +7 -0
  42. package/dist/components/list.js +143 -0
  43. package/dist/components/option-place.js +9 -0
  44. package/dist/components/option.d.ts +6 -0
  45. package/dist/components/option.js +43 -0
  46. package/dist/components/padding.d.ts +2 -0
  47. package/dist/components/padding.js +27 -0
  48. package/dist/components/pressable.js +17 -0
  49. package/dist/components/qr-code.d.ts +6 -0
  50. package/dist/components/qr-code.js +58 -0
  51. package/dist/components/scroll.d.ts +6 -0
  52. package/dist/components/scroll.js +55 -0
  53. package/dist/components/select.d.ts +6 -0
  54. package/dist/components/select.js +92 -0
  55. package/dist/components/sheet.d.ts +8 -0
  56. package/dist/components/sheet.js +105 -0
  57. package/dist/components/skeleton.d.ts +6 -0
  58. package/dist/components/skeleton.js +55 -0
  59. package/dist/components/spinner.d.ts +6 -0
  60. package/dist/components/spinner.js +48 -0
  61. package/dist/components/tabs.d.ts +7 -0
  62. package/dist/components/tabs.js +91 -0
  63. package/dist/components/text-area.d.ts +6 -0
  64. package/dist/components/text-area.js +42 -0
  65. package/dist/components/text.d.ts +6 -0
  66. package/dist/components/text.js +46 -0
  67. package/dist/components/toast.d.ts +6 -0
  68. package/dist/components/toast.js +56 -0
  69. package/dist/components/toggles.d.ts +9 -0
  70. package/dist/components/toggles.js +149 -0
  71. package/dist/components/tokens.js +37 -0
  72. package/dist/components/tones.js +24 -0
  73. package/dist/components/typed-text.js +28 -0
  74. package/dist/components/view.d.ts +6 -0
  75. package/dist/components/view.js +51 -0
  76. package/dist/index.d.ts +35 -64
  77. package/dist/index.js +32 -22636
  78. package/dist/page-root.d.ts +2 -0
  79. package/dist/page-root.js +20 -0
  80. package/dist/portal.js +8 -0
  81. package/dist/renderer.d.ts +17 -0
  82. package/dist/renderer.js +33 -0
  83. package/dist/root.d.ts +10 -0
  84. package/dist/root.js +51 -0
  85. package/dist/styles.css +95 -1
  86. package/dist/theme.d.ts +25 -0
  87. package/dist/theme.js +84 -0
  88. package/dist/types.d.ts +7 -0
  89. package/dist/vendor/@base-ui/react/checkbox/indicator/CheckboxIndicator.js +51 -0
  90. package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRoot.js +265 -0
  91. package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootContext.js +13 -0
  92. package/dist/vendor/@base-ui/react/checkbox/root/CheckboxRootDataAttributes.js +11 -0
  93. package/dist/vendor/@base-ui/react/checkbox/utils/getCheckboxStateAttributesMapping.js +15 -0
  94. package/dist/vendor/@base-ui/react/checkbox-group/CheckboxGroupContext.js +10 -0
  95. package/dist/vendor/@base-ui/react/dialog/backdrop/DialogBackdrop.js +40 -0
  96. package/dist/vendor/@base-ui/react/dialog/close/DialogClose.js +39 -0
  97. package/dist/vendor/@base-ui/react/dialog/popup/DialogPopup.js +92 -0
  98. package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupCssVars.js +8 -0
  99. package/dist/vendor/@base-ui/react/dialog/popup/DialogPopupDataAttributes.js +7 -0
  100. package/dist/vendor/@base-ui/react/dialog/portal/DialogPortal.js +38 -0
  101. package/dist/vendor/@base-ui/react/dialog/portal/DialogPortalContext.js +13 -0
  102. package/dist/vendor/@base-ui/react/dialog/root/DialogRoot.js +16 -0
  103. package/dist/vendor/@base-ui/react/dialog/root/DialogRootContext.js +13 -0
  104. package/dist/vendor/@base-ui/react/dialog/root/useDialogRoot.js +77 -0
  105. package/dist/vendor/@base-ui/react/dialog/root/useRenderDialogRoot.js +65 -0
  106. package/dist/vendor/@base-ui/react/dialog/store/DialogStore.js +70 -0
  107. package/dist/vendor/@base-ui/react/dialog/title/DialogTitle.js +25 -0
  108. package/dist/vendor/@base-ui/react/dialog/utils/stateAttributesMapping.js +17 -0
  109. package/dist/vendor/@base-ui/react/field/control/FieldControlDataAttributes.js +11 -0
  110. package/dist/vendor/@base-ui/react/field/item/FieldItemContext.js +10 -0
  111. package/dist/vendor/@base-ui/react/field/root/useFieldValidation.js +18 -0
  112. package/dist/vendor/@base-ui/react/fieldset/root/FieldsetRootContext.js +13 -0
  113. package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingFocusManager.js +477 -0
  114. package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingPortal.js +165 -0
  115. package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingRootStore.js +65 -0
  116. package/dist/vendor/@base-ui/react/floating-ui-react/components/FloatingTree.js +22 -0
  117. package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useDismiss.js +373 -0
  118. package/dist/vendor/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.js +58 -0
  119. package/dist/vendor/@base-ui/react/floating-ui-react/utils/composite.js +40 -0
  120. package/dist/vendor/@base-ui/react/floating-ui-react/utils/constants.js +5 -0
  121. package/dist/vendor/@base-ui/react/floating-ui-react/utils/createAttribute.js +6 -0
  122. package/dist/vendor/@base-ui/react/floating-ui-react/utils/createEventEmitter.js +18 -0
  123. package/dist/vendor/@base-ui/react/floating-ui-react/utils/element.js +26 -0
  124. package/dist/vendor/@base-ui/react/floating-ui-react/utils/enqueueFocus.js +25 -0
  125. package/dist/vendor/@base-ui/react/floating-ui-react/utils/event.js +25 -0
  126. package/dist/vendor/@base-ui/react/floating-ui-react/utils/markOthers.js +116 -0
  127. package/dist/vendor/@base-ui/react/floating-ui-react/utils/nodes.js +16 -0
  128. package/dist/vendor/@base-ui/react/floating-ui-react/utils/tabbable.js +135 -0
  129. package/dist/vendor/@base-ui/react/internals/TransitionStatusDataAttributes.js +11 -0
  130. package/dist/vendor/@base-ui/react/internals/composite/composite.js +89 -0
  131. package/dist/vendor/@base-ui/react/internals/composite/constants.js +4 -0
  132. package/dist/vendor/@base-ui/react/internals/composite/item/CompositeItem.js +21 -0
  133. package/dist/vendor/@base-ui/react/internals/composite/item/useCompositeItem.js +31 -0
  134. package/dist/vendor/@base-ui/react/internals/composite/list/CompositeList.js +180 -0
  135. package/dist/vendor/@base-ui/react/internals/composite/list/CompositeListContext.js +15 -0
  136. package/dist/vendor/@base-ui/react/internals/composite/list/useCompositeListItem.js +54 -0
  137. package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRoot.js +62 -0
  138. package/dist/vendor/@base-ui/react/internals/composite/root/CompositeRootContext.js +13 -0
  139. package/dist/vendor/@base-ui/react/internals/composite/root/useCompositeRoot.js +170 -0
  140. package/dist/vendor/@base-ui/react/internals/constants.js +18 -0
  141. package/dist/vendor/@base-ui/react/internals/createBaseUIEventDetails.js +40 -0
  142. package/dist/vendor/@base-ui/react/internals/direction-context/DirectionContext.js +10 -0
  143. package/dist/vendor/@base-ui/react/internals/field-constants/constants.js +33 -0
  144. package/dist/vendor/@base-ui/react/internals/field-register-control/useRegisterFieldControl.js +40 -0
  145. package/dist/vendor/@base-ui/react/internals/field-root-context/FieldRootContext.js +45 -0
  146. package/dist/vendor/@base-ui/react/internals/form-context/FormContext.js +18 -0
  147. package/dist/vendor/@base-ui/react/internals/getStateAttributesProps.js +17 -0
  148. package/dist/vendor/@base-ui/react/internals/labelable-provider/LabelableContext.js +24 -0
  149. package/dist/vendor/@base-ui/react/internals/labelable-provider/useAriaLabelledBy.js +35 -0
  150. package/dist/vendor/@base-ui/react/internals/labelable-provider/useLabelableId.js +57 -0
  151. package/dist/vendor/@base-ui/react/internals/reason-parts.js +14 -0
  152. package/dist/vendor/@base-ui/react/internals/serializeValue.js +12 -0
  153. package/dist/vendor/@base-ui/react/internals/stateAttributesMapping.js +11 -0
  154. package/dist/vendor/@base-ui/react/internals/use-button/useButton.js +137 -0
  155. package/dist/vendor/@base-ui/react/internals/useAnimationsFinished.js +94 -0
  156. package/dist/vendor/@base-ui/react/internals/useBaseUiId.js +13 -0
  157. package/dist/vendor/@base-ui/react/internals/useOpenChangeComplete.js +28 -0
  158. package/dist/vendor/@base-ui/react/internals/useRenderElement.js +109 -0
  159. package/dist/vendor/@base-ui/react/internals/useTransitionStatus.js +70 -0
  160. package/dist/vendor/@base-ui/react/internals/useValueChanged.js +15 -0
  161. package/dist/vendor/@base-ui/react/merge-props/mergeProps.js +153 -0
  162. package/dist/vendor/@base-ui/react/radio/indicator/RadioIndicator.js +46 -0
  163. package/dist/vendor/@base-ui/react/radio/root/RadioRoot.js +179 -0
  164. package/dist/vendor/@base-ui/react/radio/root/RadioRootContext.js +13 -0
  165. package/dist/vendor/@base-ui/react/radio/root/RadioRootDataAttributes.js +11 -0
  166. package/dist/vendor/@base-ui/react/radio/utils/stateAttributesMapping.js +14 -0
  167. package/dist/vendor/@base-ui/react/radio-group/RadioGroup.js +170 -0
  168. package/dist/vendor/@base-ui/react/radio-group/RadioGroupContext.js +10 -0
  169. package/dist/vendor/@base-ui/react/switch/root/SwitchRoot.js +170 -0
  170. package/dist/vendor/@base-ui/react/switch/root/SwitchRootContext.js +13 -0
  171. package/dist/vendor/@base-ui/react/switch/root/SwitchRootDataAttributes.js +11 -0
  172. package/dist/vendor/@base-ui/react/switch/stateAttributesMapping.js +12 -0
  173. package/dist/vendor/@base-ui/react/switch/thumb/SwitchThumb.js +25 -0
  174. package/dist/vendor/@base-ui/react/tabs/list/TabsList.js +98 -0
  175. package/dist/vendor/@base-ui/react/tabs/list/TabsListContext.js +13 -0
  176. package/dist/vendor/@base-ui/react/tabs/root/TabsRoot.js +213 -0
  177. package/dist/vendor/@base-ui/react/tabs/root/TabsRootContext.js +16 -0
  178. package/dist/vendor/@base-ui/react/tabs/root/TabsRootDataAttributes.js +8 -0
  179. package/dist/vendor/@base-ui/react/tabs/root/stateAttributesMapping.js +5 -0
  180. package/dist/vendor/@base-ui/react/tabs/tab/TabsTab.js +137 -0
  181. package/dist/vendor/@base-ui/react/utils/CommonPopupDataAttributes.js +24 -0
  182. package/dist/vendor/@base-ui/react/utils/CommonTriggerDataAttributes.js +11 -0
  183. package/dist/vendor/@base-ui/react/utils/FocusGuard.js +32 -0
  184. package/dist/vendor/@base-ui/react/utils/InternalBackdrop.js +30 -0
  185. package/dist/vendor/@base-ui/react/utils/dispatchClickWithModifiers.js +25 -0
  186. package/dist/vendor/@base-ui/react/utils/popupStateMapping.js +22 -0
  187. package/dist/vendor/@base-ui/react/utils/popups/popupStoreUtils.js +247 -0
  188. package/dist/vendor/@base-ui/react/utils/popups/popupTriggerMap.js +96 -0
  189. package/dist/vendor/@base-ui/react/utils/popups/store.js +94 -0
  190. package/dist/vendor/@base-ui/react/utils/resolveClassName.js +13 -0
  191. package/dist/vendor/@base-ui/react/utils/resolveRef.js +11 -0
  192. package/dist/vendor/@base-ui/react/utils/resolveStyle.js +13 -0
  193. package/dist/vendor/@base-ui/react/utils/useFocusableWhenDisabled.js +30 -0
  194. package/dist/vendor/@base-ui/utils/addEventListener.js +12 -0
  195. package/dist/vendor/@base-ui/utils/createLogOnce.js +20 -0
  196. package/dist/vendor/@base-ui/utils/empty.js +6 -0
  197. package/dist/vendor/@base-ui/utils/error.js +5 -0
  198. package/dist/vendor/@base-ui/utils/fastHooks.js +68 -0
  199. package/dist/vendor/@base-ui/utils/formatErrorMessage.js +27 -0
  200. package/dist/vendor/@base-ui/utils/getDefaultFormSubmitter.js +25 -0
  201. package/dist/vendor/@base-ui/utils/getReactElementRef.js +14 -0
  202. package/dist/vendor/@base-ui/utils/inertValue.js +8 -0
  203. package/dist/vendor/@base-ui/utils/isElementDisabled.js +6 -0
  204. package/dist/vendor/@base-ui/utils/mergeCleanups.js +14 -0
  205. package/dist/vendor/@base-ui/utils/mergeObjects.js +11 -0
  206. package/dist/vendor/@base-ui/utils/owner.js +7 -0
  207. package/dist/vendor/@base-ui/utils/platform/engine.js +8 -0
  208. package/dist/vendor/@base-ui/utils/platform/env.js +6 -0
  209. package/dist/vendor/@base-ui/utils/platform/os.js +15 -0
  210. package/dist/vendor/@base-ui/utils/platform/screen-reader.js +9 -0
  211. package/dist/vendor/@base-ui/utils/platform/shared.js +36 -0
  212. package/dist/vendor/@base-ui/utils/reactVersion.js +8 -0
  213. package/dist/vendor/@base-ui/utils/safeReact.js +13 -0
  214. package/dist/vendor/@base-ui/utils/shadowDom.js +26 -0
  215. package/dist/vendor/@base-ui/utils/store/ReactStore.js +181 -0
  216. package/dist/vendor/@base-ui/utils/store/Store.js +102 -0
  217. package/dist/vendor/@base-ui/utils/store/useStore.js +97 -0
  218. package/dist/vendor/@base-ui/utils/useAnimationFrame.js +87 -0
  219. package/dist/vendor/@base-ui/utils/useControlled.js +52 -0
  220. package/dist/vendor/@base-ui/utils/useId.js +32 -0
  221. package/dist/vendor/@base-ui/utils/useIsoLayoutEffect.js +7 -0
  222. package/dist/vendor/@base-ui/utils/useMergedRefs.js +87 -0
  223. package/dist/vendor/@base-ui/utils/useOnMount.js +12 -0
  224. package/dist/vendor/@base-ui/utils/useRefWithInit.js +18 -0
  225. package/dist/vendor/@base-ui/utils/useScrollLock.js +206 -0
  226. package/dist/vendor/@base-ui/utils/useStableCallback.js +38 -0
  227. package/dist/vendor/@base-ui/utils/useTimeout.js +43 -0
  228. package/dist/vendor/@base-ui/utils/useValueAsRef.js +27 -0
  229. package/dist/vendor/@base-ui/utils/visuallyHidden.js +23 -0
  230. package/dist/vendor/@base-ui/utils/warn.js +5 -0
  231. package/dist/vendor/@floating-ui/utils/dist/floating-ui.utils.dom.js +49 -0
  232. package/dist/vendor/uqr/dist/index.js +858 -0
  233. package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +74 -0
  234. package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +77 -0
  235. package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +69 -0
  236. package/dist/vendor/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +64 -0
  237. package/dist/vendor/use-sync-external-store/shim/index.js +11 -0
  238. package/dist/vendor/use-sync-external-store/shim/with-selector.js +11 -0
  239. package/package.json +8 -14
  240. package/dist/garra-versions.json +0 -7
@@ -0,0 +1,22 @@
1
+ import { transitionStatusMapping } from "../internals/stateAttributesMapping.js";
2
+ import { anchorHidden, closed, open } from "./CommonPopupDataAttributes.js";
3
+ import "./CommonTriggerDataAttributes.js";
4
+ const POPUP_OPEN_HOOK = { [open]: "" };
5
+ const POPUP_CLOSED_HOOK = { [closed]: "" };
6
+ const ANCHOR_HIDDEN_HOOK = { [anchorHidden]: "" };
7
+ const popupStateMapping = {
8
+ open(value) {
9
+ if (value) return POPUP_OPEN_HOOK;
10
+ return POPUP_CLOSED_HOOK;
11
+ },
12
+ anchorHidden(value) {
13
+ if (value) return ANCHOR_HIDDEN_HOOK;
14
+ return null;
15
+ }
16
+ };
17
+ const popupTransitionStateMapping = {
18
+ ...popupStateMapping,
19
+ ...transitionStatusMapping
20
+ };
21
+ //#endregion
22
+ export { popupStateMapping, popupTransitionStateMapping };
@@ -0,0 +1,247 @@
1
+ "use client";
2
+ import { useRefWithInit } from "../../../utils/useRefWithInit.js";
3
+ import { EMPTY_OBJECT } from "../../../utils/empty.js";
4
+ import { useStableCallback } from "../../../utils/useStableCallback.js";
5
+ import { useIsoLayoutEffect } from "../../../utils/useIsoLayoutEffect.js";
6
+ import { none } from "../../internals/reason-parts.js";
7
+ import { createChangeEventDetails } from "../../internals/createBaseUIEventDetails.js";
8
+ import { useId as useId$1 } from "../../../utils/useId.js";
9
+ import { FOCUSABLE_ATTRIBUTE } from "../../floating-ui-react/utils/constants.js";
10
+ import { useFloatingParentNodeId } from "../../floating-ui-react/components/FloatingTree.js";
11
+ import { useSyncedFloatingRootContext } from "../../floating-ui-react/hooks/useSyncedFloatingRootContext.js";
12
+ import { useTransitionStatus } from "../../internals/useTransitionStatus.js";
13
+ import { useOpenChangeComplete } from "../../internals/useOpenChangeComplete.js";
14
+ import * as React from "react";
15
+ import "react-dom";
16
+ //#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/utils/popups/popupStoreUtils.mjs
17
+ const FOCUSABLE_POPUP_PROPS = {
18
+ tabIndex: -1,
19
+ [FOCUSABLE_ATTRIBUTE]: ""
20
+ };
21
+ /**
22
+ * Returns the default `initialFocus` resolver for a popup. When opened by touch it focuses the
23
+ * popup element itself to prevent the virtual keyboard from opening (required for Android
24
+ * specifically; iOS handles this automatically). Otherwise it falls back to the default behavior.
25
+ */
26
+ function createDefaultInitialFocus(popupRef) {
27
+ return (interactionType) => interactionType === "touch" ? popupRef.current : true;
28
+ }
29
+ /**
30
+ * The subset of a popup handle that a Root needs to bind its store to. Both the real handle classes
31
+ * and any test double satisfy it.
32
+ */
33
+ /**
34
+ * Creates and owns a popup store on behalf of a Root part. The store is created exactly once, with
35
+ * controlled props and root state synced separately after creation. Sets up the synced floating
36
+ * root context and returns the store.
37
+ *
38
+ * @param createStore Factory that builds the store. Called exactly once, receiving the floating id
39
+ * and whether the popup is nested inside another floating element, both resolved on the first render.
40
+ * @param treatPopupAsFloatingElement Whether the popup element is passed to Floating UI as the
41
+ * floating element instead of the default positioner.
42
+ */
43
+ function usePopupRootStore(createStore, treatPopupAsFloatingElement = false) {
44
+ const floatingId = useId$1();
45
+ const nested = useFloatingParentNodeId() != null;
46
+ const store = useRefWithInit(() => createStore(floatingId, nested)).current;
47
+ useSyncedFloatingRootContext({
48
+ popupStore: store,
49
+ treatPopupAsFloatingElement,
50
+ floatingRootContext: store.state.floatingRootContext,
51
+ floatingId,
52
+ nested,
53
+ onOpenChange: store.setOpen
54
+ });
55
+ return store;
56
+ }
57
+ /**
58
+ * Attaches a Root's store to a handle for this component's committed lifetime. Popup Roots render
59
+ * it before their interactions and user children so its layout effect runs before descendant layout
60
+ * effects. This lets descendants call the handle during the Root's initial commit without attaching
61
+ * during render, which would leak suspended or abandoned stores. Store subscribers are notified by
62
+ * `attachStore` in this ordinary layout phase, where React permits synchronous updates.
63
+ *
64
+ * Popup Roots must render this component only when a handle is present so handle-less Roots avoid
65
+ * mounting an extra fiber and layout effect.
66
+ */
67
+ function PopupHandleAttachment({ handle, store }) {
68
+ useIsoLayoutEffect(() => {
69
+ return handle.attachStore(store);
70
+ }, [handle, store]);
71
+ return null;
72
+ }
73
+ function createPopupOpenState(state, open, trigger, preventUnmountOnClose = false) {
74
+ let preventUnmountingOnClose = state.preventUnmountingOnClose;
75
+ if (open) preventUnmountingOnClose = false;
76
+ else if (preventUnmountOnClose) preventUnmountingOnClose = true;
77
+ const triggerId = trigger?.id ?? null;
78
+ let activeTriggerId = state.activeTriggerId;
79
+ let activeTriggerElement = state.activeTriggerElement;
80
+ if (triggerId || open) {
81
+ activeTriggerId = triggerId;
82
+ activeTriggerElement = trigger ?? null;
83
+ }
84
+ return {
85
+ open,
86
+ preventUnmountingOnClose,
87
+ activeTriggerId,
88
+ activeTriggerElement
89
+ };
90
+ }
91
+ /**
92
+ * Keeps trigger registration state synchronized while the popup is open.
93
+ *
94
+ * When a popup opens without an explicit trigger id and exactly one trigger is registered, that
95
+ * trigger is claimed as the active trigger. When the active trigger id is still registered but its
96
+ * element changed, the active element is refreshed. When the active trigger id is missing from the
97
+ * registry but the same element is still registered under a different id (e.g. the rendered trigger
98
+ * carries its own DOM `id` that differs from Base UI's internal trigger id), the active id is
99
+ * reassociated to the registered id instead of being treated as lost. When the active trigger
100
+ * unregisters, the default path preserves existing ownership so non-closing popup families do not
101
+ * silently claim a different trigger while staying open.
102
+ *
103
+ * If `closeOnActiveTriggerUnmount` is enabled, unregistering a previously resolved active trigger
104
+ * requests a close after a microtask so a same-tick replacement trigger with the same id can
105
+ * register first. An active trigger id that has not matched a registered trigger yet is treated as
106
+ * pending and does not request a close.
107
+ *
108
+ * This should be called on the Root part.
109
+ *
110
+ * @param store The Store instance managing the popup state.
111
+ * @param options Options for active trigger unmount behavior.
112
+ */
113
+ function useImplicitActiveTrigger(store, options = {}) {
114
+ const { closeOnActiveTriggerUnmount = false } = options;
115
+ const resolvedActiveTriggerIdRef = React.useRef(null);
116
+ const open = store.useState("open");
117
+ const reactiveTriggerCount = store.useState("triggerCount");
118
+ const activeTriggerId = store.useState("activeTriggerId");
119
+ const reactiveActiveTriggerElement = store.useState("activeTriggerElement");
120
+ useIsoLayoutEffect(() => {
121
+ if (!open) {
122
+ resolvedActiveTriggerIdRef.current = null;
123
+ if (store.state.triggerCount !== 0) store.set("triggerCount", 0);
124
+ return;
125
+ }
126
+ const triggerCount = store.context.triggerElements.size;
127
+ const stateUpdates = {};
128
+ if (store.state.triggerCount !== triggerCount) stateUpdates.triggerCount = triggerCount;
129
+ const currentActiveTriggerId = store.select("activeTriggerId");
130
+ let lostActiveTriggerId = null;
131
+ if (currentActiveTriggerId) {
132
+ const activeTriggerElement = store.context.triggerElements.getById(currentActiveTriggerId);
133
+ if (!activeTriggerElement) {
134
+ for (const [triggerId, triggerElement] of store.context.triggerElements.entries()) if (triggerElement === store.state.activeTriggerElement) {
135
+ stateUpdates.activeTriggerId = triggerId;
136
+ stateUpdates.activeTriggerElement = triggerElement;
137
+ resolvedActiveTriggerIdRef.current = triggerId;
138
+ break;
139
+ }
140
+ if (stateUpdates.activeTriggerId === void 0) {
141
+ if (resolvedActiveTriggerIdRef.current === currentActiveTriggerId) lostActiveTriggerId = currentActiveTriggerId;
142
+ else resolvedActiveTriggerIdRef.current = null;
143
+ }
144
+ } else {
145
+ resolvedActiveTriggerIdRef.current = currentActiveTriggerId;
146
+ if (activeTriggerElement !== store.state.activeTriggerElement) stateUpdates.activeTriggerElement = activeTriggerElement;
147
+ }
148
+ } else resolvedActiveTriggerIdRef.current = null;
149
+ if (!lostActiveTriggerId && !currentActiveTriggerId && triggerCount === 1) {
150
+ const iteratorResult = store.context.triggerElements.entries().next();
151
+ if (!iteratorResult.done) {
152
+ const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
153
+ stateUpdates.activeTriggerId = implicitTriggerId;
154
+ stateUpdates.activeTriggerElement = implicitTriggerElement;
155
+ resolvedActiveTriggerIdRef.current = implicitTriggerId;
156
+ }
157
+ }
158
+ if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) store.update(stateUpdates);
159
+ if (lostActiveTriggerId) {
160
+ if (closeOnActiveTriggerUnmount) queueMicrotask(() => {
161
+ if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) {
162
+ const eventDetails = createChangeEventDetails(none);
163
+ store.setOpen(false, eventDetails);
164
+ if (!eventDetails.isCanceled) store.update({
165
+ activeTriggerId: null,
166
+ activeTriggerElement: null
167
+ });
168
+ }
169
+ });
170
+ }
171
+ }, [
172
+ open,
173
+ store,
174
+ reactiveTriggerCount,
175
+ activeTriggerId,
176
+ reactiveActiveTriggerElement,
177
+ closeOnActiveTriggerUnmount
178
+ ]);
179
+ }
180
+ /**
181
+ * Manages the mounted state of the popup.
182
+ * Sets up the transition status listeners and handles unmounting when needed.
183
+ * Updates the `mounted`, `transitionStatus`, and `preventUnmountingOnClose` states in the store.
184
+ *
185
+ * @param open Whether the popup is open.
186
+ * @param store The Store instance managing the popup state.
187
+ * @param onUnmount Optional callback to be called when the popup is unmounted.
188
+ * @param animateInitialOpen Whether a popup that mounts already open should still play its enter
189
+ * transition. Defaults to `false`, so content that was open on the first render (a `defaultOpen`
190
+ * popup on page load, SSR'd markup) appears without animating. Opt in for popups whose subtree
191
+ * only mounts in response to something the user did, such as a submenu inside a menu popup.
192
+ *
193
+ * @returns A function to forcibly unmount the popup.
194
+ */
195
+ function useOpenStateTransitions(open, store, onUnmount, animateInitialOpen) {
196
+ const { mounted, setMounted, transitionStatus } = useTransitionStatus(open, false, false, animateInitialOpen);
197
+ const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
198
+ const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose;
199
+ store.useSyncedValues({
200
+ mounted,
201
+ transitionStatus,
202
+ preventUnmountingOnClose: syncedPreventUnmountingOnClose
203
+ });
204
+ const forceUnmount = useStableCallback(() => {
205
+ setMounted(false);
206
+ store.update({
207
+ activeTriggerId: null,
208
+ activeTriggerElement: null,
209
+ mounted: false,
210
+ preventUnmountingOnClose: false
211
+ });
212
+ onUnmount?.();
213
+ store.context.onOpenChangeComplete?.(false);
214
+ });
215
+ useOpenChangeComplete({
216
+ enabled: mounted && !open && !syncedPreventUnmountingOnClose,
217
+ open,
218
+ ref: store.context.popupRef,
219
+ onComplete() {
220
+ if (!open) forceUnmount();
221
+ }
222
+ });
223
+ return {
224
+ forceUnmount,
225
+ transitionStatus
226
+ };
227
+ }
228
+ function usePopupInteractionProps(store, statePart) {
229
+ store.useSyncedValues(statePart);
230
+ useIsoLayoutEffect(() => () => {
231
+ store.update({
232
+ activeTriggerProps: EMPTY_OBJECT,
233
+ inactiveTriggerProps: EMPTY_OBJECT,
234
+ popupProps: EMPTY_OBJECT
235
+ });
236
+ }, [store]);
237
+ }
238
+ function usePopupRootSync(store, open) {
239
+ useIsoLayoutEffect(() => {
240
+ if (!open && store.state.openMethod !== null) store.set("openMethod", null);
241
+ }, [open, store]);
242
+ useIsoLayoutEffect(() => () => {
243
+ if (store.state.openMethod !== null) store.set("openMethod", null);
244
+ }, [store]);
245
+ }
246
+ //#endregion
247
+ export { FOCUSABLE_POPUP_PROPS, PopupHandleAttachment, createDefaultInitialFocus, createPopupOpenState, useImplicitActiveTrigger, useOpenStateTransitions, usePopupInteractionProps, usePopupRootStore, usePopupRootSync };
@@ -0,0 +1,96 @@
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/utils/popups/popupTriggerMap.mjs
2
+ /**
3
+ * Development-only reverse index of element to registered id, keyed by the owning map.
4
+ *
5
+ * Registration would otherwise have to scan every entry to detect an element claimed by two ids,
6
+ * making the mount of many triggers sharing one handle quadratic. Kept module-scoped, lazily
7
+ * initialized, and read only from `process.env.NODE_ENV` guards so production builds drop it along
8
+ * with the checks.
9
+ */
10
+ let devElementIdsByMap;
11
+ function getDevElementIds(map) {
12
+ devElementIdsByMap ??= /* @__PURE__ */ new WeakMap();
13
+ let elementIds = devElementIdsByMap.get(map);
14
+ if (!elementIds) {
15
+ elementIds = /* @__PURE__ */ new WeakMap();
16
+ devElementIdsByMap.set(map, elementIds);
17
+ }
18
+ return elementIds;
19
+ }
20
+ /**
21
+ * Data structure to keep track of popup trigger elements by their IDs.
22
+ *
23
+ * Element lookups iterate the id map rather than maintaining a parallel Set. Registration is O(1),
24
+ * while `hasElement` and `hasMatchingElement` are linear in the number of triggers.
25
+ */
26
+ var PopupTriggerMap = class {
27
+ constructor() {
28
+ this.idMap = /* @__PURE__ */ new Map();
29
+ }
30
+ /**
31
+ * Adds a trigger element with the given ID.
32
+ *
33
+ * Note: The provided element is assumed to not be registered under multiple IDs.
34
+ */
35
+ add(id, element) {
36
+ if (process.env.NODE_ENV !== "production") {
37
+ const elementIds = getDevElementIds(this);
38
+ const existingId = elementIds.get(element);
39
+ if (existingId !== void 0 && existingId !== id) throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
40
+ const previousElement = this.idMap.get(id);
41
+ if (previousElement !== void 0 && previousElement !== element) elementIds.delete(previousElement);
42
+ elementIds.set(element, id);
43
+ }
44
+ this.idMap.set(id, element);
45
+ }
46
+ /**
47
+ * Removes the trigger element with the given ID.
48
+ */
49
+ delete(id) {
50
+ if (process.env.NODE_ENV !== "production") {
51
+ const element = this.idMap.get(id);
52
+ if (element !== void 0) devElementIdsByMap?.get(this)?.delete(element);
53
+ }
54
+ this.idMap.delete(id);
55
+ }
56
+ /**
57
+ * Whether the given element is registered as a trigger.
58
+ */
59
+ hasElement(element) {
60
+ for (const registered of this.idMap.values()) if (registered === element) return true;
61
+ return false;
62
+ }
63
+ /**
64
+ * Whether there is a registered trigger element matching the given predicate.
65
+ */
66
+ hasMatchingElement(predicate) {
67
+ for (const element of this.idMap.values()) if (predicate(element)) return true;
68
+ return false;
69
+ }
70
+ /**
71
+ * Returns the trigger element associated with the given ID, or undefined if no such element exists.
72
+ */
73
+ getById(id) {
74
+ return this.idMap.get(id);
75
+ }
76
+ /**
77
+ * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
78
+ */
79
+ entries() {
80
+ return this.idMap.entries();
81
+ }
82
+ /**
83
+ * Returns an iterable of all registered trigger elements.
84
+ */
85
+ elements() {
86
+ return this.idMap.values();
87
+ }
88
+ /**
89
+ * Returns the number of registered trigger elements.
90
+ */
91
+ get size() {
92
+ return this.idMap.size;
93
+ }
94
+ };
95
+ //#endregion
96
+ export { PopupTriggerMap };
@@ -0,0 +1,94 @@
1
+ import { EMPTY_OBJECT } from "../../../utils/empty.js";
2
+ import { FloatingRootStore } from "../../floating-ui-react/components/FloatingRootStore.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/utils/popups/store.mjs
4
+ /**
5
+ * State common to all popup stores.
6
+ */
7
+ function createInitialPopupStoreState(triggerElements, floatingId, nested = false) {
8
+ return {
9
+ open: false,
10
+ openProp: void 0,
11
+ mounted: false,
12
+ transitionStatus: void 0,
13
+ floatingRootContext: new FloatingRootStore({
14
+ open: false,
15
+ transitionStatus: void 0,
16
+ floatingElement: null,
17
+ referenceElement: null,
18
+ triggerElements,
19
+ floatingId,
20
+ syncOnly: true,
21
+ nested,
22
+ onOpenChange: void 0
23
+ }),
24
+ floatingId,
25
+ triggerCount: 0,
26
+ preventUnmountingOnClose: false,
27
+ payload: void 0,
28
+ activeTriggerId: null,
29
+ activeTriggerElement: null,
30
+ triggerIdProp: void 0,
31
+ popupElement: null,
32
+ positionerElement: null,
33
+ activeTriggerProps: EMPTY_OBJECT,
34
+ inactiveTriggerProps: EMPTY_OBJECT,
35
+ popupProps: EMPTY_OBJECT
36
+ };
37
+ }
38
+ const activeTriggerIdSelector = (state) => state.triggerIdProp ?? state.activeTriggerId;
39
+ const openSelector = (state) => state.openProp ?? state.open;
40
+ const popupIdSelector = (state) => {
41
+ return (state.popupElement?.id ?? state.floatingId) || void 0;
42
+ };
43
+ function triggerOwnsOpenPopup(state, triggerId) {
44
+ return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
45
+ }
46
+ function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
47
+ if (triggerOwnsOpenPopup(state, triggerId)) return true;
48
+ return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
49
+ }
50
+ const popupStoreSelectors = {
51
+ open: openSelector,
52
+ mounted: (state) => state.mounted,
53
+ transitionStatus: (state) => state.transitionStatus,
54
+ floatingRootContext: (state) => state.floatingRootContext,
55
+ triggerCount: (state) => state.triggerCount,
56
+ preventUnmountingOnClose: (state) => state.preventUnmountingOnClose,
57
+ payload: (state) => state.payload,
58
+ activeTriggerId: activeTriggerIdSelector,
59
+ activeTriggerElement: (state) => state.mounted ? state.activeTriggerElement : null,
60
+ popupId: popupIdSelector,
61
+ /**
62
+ * Whether the trigger with the given ID was used to open the popup.
63
+ */
64
+ isTriggerActive: (state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId,
65
+ /**
66
+ * Whether the popup is open and was activated by a trigger with the given ID.
67
+ */
68
+ isOpenedByTrigger: (state, triggerId) => triggerOwnsOpenPopup(state, triggerId),
69
+ /**
70
+ * Whether the popup is mounted and was activated by a trigger with the given ID.
71
+ */
72
+ isMountedByTrigger: (state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted,
73
+ triggerProps: (state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps,
74
+ /**
75
+ * Popup id for the trigger that currently owns the open popup.
76
+ */
77
+ triggerPopupId: (state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0,
78
+ popupProps: (state) => state.popupProps,
79
+ popupElement: (state) => state.popupElement,
80
+ positionerElement: (state) => state.positionerElement
81
+ };
82
+ /**
83
+ * Store members a detached handle-backed trigger reads or invokes for trigger registration and data
84
+ * forwarding. `set`/`update` are included only for trigger-count and trigger-data bookkeeping; on a
85
+ * detached (inert) store they are intentionally no-ops, so a write through them is not guaranteed to
86
+ * be durable. Component handle-store views Pick these from their concrete store (preserving its
87
+ * context and selectors) and add any component-specific trigger-invoked members such as `setOpen`.
88
+ */
89
+ /**
90
+ * The subset of a popup store that trigger registration and data forwarding rely on. Narrow enough
91
+ * that an inert store can be passed while detached.
92
+ */
93
+ //#endregion
94
+ export { createInitialPopupStoreState, popupStoreSelectors };
@@ -0,0 +1,13 @@
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/utils/resolveClassName.mjs
2
+ /**
3
+ * If the provided className is a string, it will be returned as is.
4
+ * Otherwise, the function will call the className function with the state as the first argument.
5
+ *
6
+ * @param className
7
+ * @param state
8
+ */
9
+ function resolveClassName(className, state) {
10
+ return typeof className === "function" ? className(state) : className;
11
+ }
12
+ //#endregion
13
+ export { resolveClassName };
@@ -0,0 +1,11 @@
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/utils/resolveRef.mjs
2
+ /**
3
+ * If the provided argument is a ref object, returns its `current` value.
4
+ * Otherwise, returns the argument itself.
5
+ */
6
+ function resolveRef(maybeRef) {
7
+ if (maybeRef == null) return maybeRef;
8
+ return "current" in maybeRef ? maybeRef.current : maybeRef;
9
+ }
10
+ //#endregion
11
+ export { resolveRef };
@@ -0,0 +1,13 @@
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/utils/resolveStyle.mjs
2
+ /**
3
+ * If the provided style is an object, it will be returned as is.
4
+ * Otherwise, the function will call the style function with the state as the first argument.
5
+ *
6
+ * @param style
7
+ * @param state
8
+ */
9
+ function resolveStyle(style, state) {
10
+ return typeof style === "function" ? style(state) : style;
11
+ }
12
+ //#endregion
13
+ export { resolveStyle };
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import * as React from "react";
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/utils/useFocusableWhenDisabled.mjs
4
+ function useFocusableWhenDisabled(parameters) {
5
+ const { focusableWhenDisabled, disabled, composite = false, tabIndex: tabIndexProp = 0, isNativeButton } = parameters;
6
+ const isFocusableComposite = composite && focusableWhenDisabled !== false;
7
+ const isNonFocusableComposite = composite && focusableWhenDisabled === false;
8
+ return { props: React.useMemo(() => {
9
+ const additionalProps = { onKeyDown(event) {
10
+ if (disabled && focusableWhenDisabled && event.key !== "Tab") event.preventDefault();
11
+ } };
12
+ if (!composite) {
13
+ additionalProps.tabIndex = tabIndexProp;
14
+ if (!isNativeButton && disabled) additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
15
+ }
16
+ if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled) additionalProps["aria-disabled"] = disabled;
17
+ if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) additionalProps.disabled = disabled;
18
+ return additionalProps;
19
+ }, [
20
+ composite,
21
+ disabled,
22
+ focusableWhenDisabled,
23
+ isFocusableComposite,
24
+ isNonFocusableComposite,
25
+ isNativeButton,
26
+ tabIndexProp
27
+ ]) };
28
+ }
29
+ //#endregion
30
+ export { useFocusableWhenDisabled };
@@ -0,0 +1,12 @@
1
+ //#region ../../../node_modules/.pnpm/@base-ui+utils@0.4.0_@types+react@19.3.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/utils/addEventListener.mjs
2
+ /**
3
+ * Adds an event listener and returns a cleanup function to remove it.
4
+ */
5
+ function addEventListener(target, type, listener, options) {
6
+ target.addEventListener(type, listener, options);
7
+ return () => {
8
+ target.removeEventListener(type, listener, options);
9
+ };
10
+ }
11
+ //#endregion
12
+ export { addEventListener };
@@ -0,0 +1,20 @@
1
+ //#region ../../../node_modules/.pnpm/@base-ui+utils@0.4.0_@types+react@19.3.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/utils/createLogOnce.mjs
2
+ let loggedMessages;
3
+ if (process.env.NODE_ENV !== "production") loggedMessages = /* @__PURE__ */ new Set();
4
+ /** Creates a dev-only logger that writes each unique message to `console[severity]` once. */
5
+ function createLogOnce(severity, prefix) {
6
+ return function logOnce(...messages) {
7
+ if (process.env.NODE_ENV !== "production") {
8
+ const message = messages.join(" ");
9
+ const output = prefix ? `${prefix}: ${message}` : message;
10
+ const key = `${severity}:${output}`;
11
+ if (!loggedMessages.has(key)) {
12
+ loggedMessages.add(key);
13
+ if (severity === "warn") console.warn(output);
14
+ else console.error(output);
15
+ }
16
+ }
17
+ };
18
+ }
19
+ //#endregion
20
+ export { createLogOnce };
@@ -0,0 +1,6 @@
1
+ //#region ../../../node_modules/.pnpm/@base-ui+utils@0.4.0_@types+react@19.3.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/utils/empty.mjs
2
+ function NOOP() {}
3
+ const EMPTY_ARRAY = Object.freeze([]);
4
+ const EMPTY_OBJECT = Object.freeze({});
5
+ //#endregion
6
+ export { EMPTY_ARRAY, EMPTY_OBJECT, NOOP };
@@ -0,0 +1,5 @@
1
+ import { createLogOnce } from "./createLogOnce.js";
2
+ //#region ../../../node_modules/.pnpm/@base-ui+utils@0.4.0_@types+react@19.3.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/utils/error.mjs
3
+ const error = createLogOnce("error", "Base UI");
4
+ //#endregion
5
+ export { error };
@@ -0,0 +1,68 @@
1
+ import { useRefWithInit } from "./useRefWithInit.js";
2
+ import "react";
3
+ //#region ../../../node_modules/.pnpm/@base-ui+utils@0.4.0_@types+react@19.3.0_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/@base-ui/utils/fastHooks.mjs
4
+ const hooks = [];
5
+ let currentInstance = void 0;
6
+ function getInstance() {
7
+ return currentInstance;
8
+ }
9
+ function register(hook) {
10
+ hooks.push(hook);
11
+ }
12
+ /**
13
+ * Wraps a component function to enable performance optimizations for internal hooks.
14
+ *
15
+ * **Performance Optimization:**
16
+ * Components wrapped with `fastComponent` have access to a shared "instance" context that enables
17
+ * specialized hook implementations to batch operations and reduce overhead. The wrapper creates a
18
+ * stable instance object that persists across renders, sets it as the current context, calls
19
+ * registered hooks before and after rendering, then clears the context. The primary benefit is
20
+ * with `useStore`, where multiple store subscriptions within the same component are collapsed into
21
+ * a single `useSyncExternalStore` subscription per store, significantly reducing re-render overhead.
22
+ * This optimization is only active on React 19+; on earlier versions `useStore` falls back to a
23
+ * separate subscription per call.
24
+ *
25
+ * **Requirements:**
26
+ * - The component function should follow standard React component patterns
27
+ * - `useStore` calls must keep a stable order and count across renders, as batched hooks are
28
+ * matched by call index
29
+ * - Do not rely on the instance context outside of specialized hooks
30
+ *
31
+ * @param fn - The component function to wrap
32
+ * @returns A wrapped component with the same signature as the input function
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * // Wrapping a component to enable optimized useStore batching
37
+ * export const TooltipRoot = fastComponent(function TooltipRoot(props) {
38
+ * // These useStore calls share a single subscription
39
+ * const open = useStore(store, (state) => state.open);
40
+ * const disabled = useStore(store, (state) => state.disabled);
41
+ * const value = useStore(store, (state) => state.value);
42
+ * // ...
43
+ * });
44
+ * ```
45
+ */
46
+ function fastComponent(fn) {
47
+ const FastComponent = (props, forwardedRef) => {
48
+ const instance = useRefWithInit(createInstance).current;
49
+ let result;
50
+ try {
51
+ currentInstance = instance;
52
+ for (const hook of hooks) hook.before(instance);
53
+ result = fn(props, forwardedRef);
54
+ for (const hook of hooks) hook.after(instance);
55
+ instance.didInitialize = true;
56
+ } finally {
57
+ currentInstance = void 0;
58
+ }
59
+ return result;
60
+ };
61
+ FastComponent.displayName = fn.displayName || fn.name;
62
+ return FastComponent;
63
+ }
64
+ function createInstance() {
65
+ return { didInitialize: false };
66
+ }
67
+ //#endregion
68
+ export { fastComponent, getInstance, register };