@octanejs/base-ui 0.1.31 → 0.1.33

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 (201) hide show
  1. package/dist/cjs/accordion.cjs +497 -0
  2. package/dist/cjs/alert-dialog.cjs +65 -0
  3. package/dist/cjs/avatar.cjs +234 -0
  4. package/dist/cjs/button.cjs +54 -0
  5. package/dist/cjs/checkbox-group.cjs +165 -0
  6. package/dist/cjs/checkbox.cjs +475 -0
  7. package/dist/cjs/collapsible.cjs +700 -0
  8. package/dist/cjs/context-menu.cjs +257 -0
  9. package/dist/cjs/csp-provider.cjs +40 -0
  10. package/dist/cjs/dialog.cjs +741 -0
  11. package/dist/cjs/direction-provider.cjs +35 -0
  12. package/dist/cjs/field.cjs +559 -0
  13. package/dist/cjs/fieldset.cjs +101 -0
  14. package/dist/cjs/form.cjs +177 -0
  15. package/dist/cjs/index.cjs +133 -0
  16. package/dist/cjs/input.cjs +32 -0
  17. package/dist/cjs/internal.cjs +51 -0
  18. package/dist/cjs/menu.cjs +2420 -0
  19. package/dist/cjs/menubar.cjs +132 -0
  20. package/dist/cjs/merge-props.cjs +34 -0
  21. package/dist/cjs/meter.cjs +169 -0
  22. package/dist/cjs/number-field.cjs +812 -0
  23. package/dist/cjs/popover.cjs +966 -0
  24. package/dist/cjs/preview-card.cjs +632 -0
  25. package/dist/cjs/progress.cjs +206 -0
  26. package/dist/cjs/radio-group.cjs +264 -0
  27. package/dist/cjs/radio.cjs +327 -0
  28. package/dist/cjs/separator.cjs +44 -0
  29. package/dist/cjs/slider.cjs +1384 -0
  30. package/dist/cjs/switch.cjs +306 -0
  31. package/dist/cjs/tabs.cjs +727 -0
  32. package/dist/cjs/toast.cjs +1766 -0
  33. package/dist/cjs/toggle-group.cjs +118 -0
  34. package/dist/cjs/toggle.cjs +121 -0
  35. package/dist/cjs/tooltip.cjs +835 -0
  36. package/dist/cjs/unstable-use-media-query.cjs +79 -0
  37. package/dist/cjs/use-render.cjs +40 -0
  38. package/dist/cjs/utils/CSPContext.cjs +38 -0
  39. package/dist/cjs/utils/CheckboxGroupContext.cjs +40 -0
  40. package/dist/cjs/utils/CompositeRootContext.cjs +40 -0
  41. package/dist/cjs/utils/ContextMenuRootContext.cjs +42 -0
  42. package/dist/cjs/utils/DirectionContext.cjs +34 -0
  43. package/dist/cjs/utils/FloatingPortalLite.cjs +47 -0
  44. package/dist/cjs/utils/InternalBackdrop.cjs +49 -0
  45. package/dist/cjs/utils/MenubarContext.cjs +40 -0
  46. package/dist/cjs/utils/RadioGroupContext.cjs +34 -0
  47. package/dist/cjs/utils/RequestQueue.cjs +111 -0
  48. package/dist/cjs/utils/TimeoutManager.cjs +50 -0
  49. package/dist/cjs/utils/ToggleGroupContext.cjs +40 -0
  50. package/dist/cjs/utils/adaptiveOriginMiddleware.cjs +94 -0
  51. package/dist/cjs/utils/addEventListener.cjs +33 -0
  52. package/dist/cjs/utils/areArraysEqual.cjs +30 -0
  53. package/dist/cjs/utils/clamp.cjs +30 -0
  54. package/dist/cjs/utils/closePart.cjs +70 -0
  55. package/dist/cjs/utils/collapsibleOpenStateMapping.cjs +42 -0
  56. package/dist/cjs/utils/composeRefs.cjs +68 -0
  57. package/dist/cjs/utils/composite/CompositeItem.cjs +59 -0
  58. package/dist/cjs/utils/composite/CompositeList.cjs +177 -0
  59. package/dist/cjs/utils/composite/CompositeListContext.cjs +43 -0
  60. package/dist/cjs/utils/composite/CompositeRoot.cjs +118 -0
  61. package/dist/cjs/utils/composite/grid-utils.cjs +343 -0
  62. package/dist/cjs/utils/composite/gridNavigation.cjs +92 -0
  63. package/dist/cjs/utils/composite/keys.cjs +174 -0
  64. package/dist/cjs/utils/composite/list-utils.cjs +90 -0
  65. package/dist/cjs/utils/composite/useCompositeItem.cjs +63 -0
  66. package/dist/cjs/utils/composite/useCompositeListItem.cjs +104 -0
  67. package/dist/cjs/utils/composite/useCompositeRoot.cjs +263 -0
  68. package/dist/cjs/utils/constants.cjs +56 -0
  69. package/dist/cjs/utils/contains.cjs +46 -0
  70. package/dist/cjs/utils/createChangeEventDetails.cjs +92 -0
  71. package/dist/cjs/utils/dom.cjs +35 -0
  72. package/dist/cjs/utils/empty.cjs +34 -0
  73. package/dist/cjs/utils/field/FieldItemContext.cjs +34 -0
  74. package/dist/cjs/utils/field/FieldRootContext.cjs +80 -0
  75. package/dist/cjs/utils/field/FormContext.cjs +41 -0
  76. package/dist/cjs/utils/field/LabelableContext.cjs +43 -0
  77. package/dist/cjs/utils/field/LabelableProvider.cjs +115 -0
  78. package/dist/cjs/utils/field/constants.cjs +68 -0
  79. package/dist/cjs/utils/field/getCombinedFieldValidityData.cjs +36 -0
  80. package/dist/cjs/utils/field/useAriaLabelledBy.cjs +87 -0
  81. package/dist/cjs/utils/field/useFieldControlRegistration.cjs +165 -0
  82. package/dist/cjs/utils/field/useFieldValidation.cjs +285 -0
  83. package/dist/cjs/utils/field/useLabel.cjs +99 -0
  84. package/dist/cjs/utils/field/useLabelableId.cjs +105 -0
  85. package/dist/cjs/utils/field/useRegisterFieldControl.cjs +60 -0
  86. package/dist/cjs/utils/findRootOwnerId.cjs +37 -0
  87. package/dist/cjs/utils/floating/FloatingDelayGroup.cjs +219 -0
  88. package/dist/cjs/utils/floating/FloatingFocusManager.cjs +685 -0
  89. package/dist/cjs/utils/floating/FloatingPortal.cjs +230 -0
  90. package/dist/cjs/utils/floating/FloatingRootStore.cjs +87 -0
  91. package/dist/cjs/utils/floating/FloatingTree.cjs +86 -0
  92. package/dist/cjs/utils/floating/FloatingTreeStore.cjs +41 -0
  93. package/dist/cjs/utils/floating/FocusGuard.cjs +54 -0
  94. package/dist/cjs/utils/floating/composite.cjs +42 -0
  95. package/dist/cjs/utils/floating/constants.cjs +34 -0
  96. package/dist/cjs/utils/floating/createAttribute.cjs +30 -0
  97. package/dist/cjs/utils/floating/createEventEmitter.cjs +44 -0
  98. package/dist/cjs/utils/floating/element.cjs +103 -0
  99. package/dist/cjs/utils/floating/enqueueFocus.cjs +51 -0
  100. package/dist/cjs/utils/floating/event.cjs +65 -0
  101. package/dist/cjs/utils/floating/getEmptyRootContext.cjs +42 -0
  102. package/dist/cjs/utils/floating/gridNavigation.cjs +45 -0
  103. package/dist/cjs/utils/floating/markOthers.cjs +181 -0
  104. package/dist/cjs/utils/floating/nodes.cjs +48 -0
  105. package/dist/cjs/utils/floating/safePolygon.cjs +301 -0
  106. package/dist/cjs/utils/floating/tabbable.cjs +242 -0
  107. package/dist/cjs/utils/floating/types.cjs +16 -0
  108. package/dist/cjs/utils/floating/useClick.cjs +153 -0
  109. package/dist/cjs/utils/floating/useClientPoint.cjs +225 -0
  110. package/dist/cjs/utils/floating/useDismiss.cjs +506 -0
  111. package/dist/cjs/utils/floating/useFloating.cjs +186 -0
  112. package/dist/cjs/utils/floating/useFloatingRootContext.cjs +75 -0
  113. package/dist/cjs/utils/floating/useFocus.cjs +184 -0
  114. package/dist/cjs/utils/floating/useHoverFloatingInteraction.cjs +231 -0
  115. package/dist/cjs/utils/floating/useHoverInteractionSharedState.cjs +113 -0
  116. package/dist/cjs/utils/floating/useHoverReferenceInteraction.cjs +380 -0
  117. package/dist/cjs/utils/floating/useHoverShared.cjs +65 -0
  118. package/dist/cjs/utils/floating/useListNavigation.cjs +665 -0
  119. package/dist/cjs/utils/floating/useSyncedFloatingRootContext.cjs +91 -0
  120. package/dist/cjs/utils/floating/useTypeahead.cjs +187 -0
  121. package/dist/cjs/utils/formatNumber.cjs +60 -0
  122. package/dist/cjs/utils/generateId.cjs +32 -0
  123. package/dist/cjs/utils/getCssDimensions.cjs +42 -0
  124. package/dist/cjs/utils/getDefaultFormSubmitter.cjs +42 -0
  125. package/dist/cjs/utils/getDisabledMountTransitionStyles.cjs +32 -0
  126. package/dist/cjs/utils/getElementRef.cjs +35 -0
  127. package/dist/cjs/utils/getPseudoElementBounds.cjs +56 -0
  128. package/dist/cjs/utils/getStateAttributesProps.cjs +46 -0
  129. package/dist/cjs/utils/hideMiddleware.cjs +42 -0
  130. package/dist/cjs/utils/inertValue.cjs +30 -0
  131. package/dist/cjs/utils/matchesFocusVisible.cjs +38 -0
  132. package/dist/cjs/utils/mergeCleanups.cjs +37 -0
  133. package/dist/cjs/utils/mergeObjects.cjs +39 -0
  134. package/dist/cjs/utils/mergeProps.cjs +182 -0
  135. package/dist/cjs/utils/noop.cjs +29 -0
  136. package/dist/cjs/utils/number/constants.cjs +34 -0
  137. package/dist/cjs/utils/number/parse.cjs +258 -0
  138. package/dist/cjs/utils/number/types.cjs +16 -0
  139. package/dist/cjs/utils/number/validate.cjs +104 -0
  140. package/dist/cjs/utils/owner.cjs +35 -0
  141. package/dist/cjs/utils/platform.cjs +83 -0
  142. package/dist/cjs/utils/popupStateMapping.cjs +74 -0
  143. package/dist/cjs/utils/popups/index.cjs +39 -0
  144. package/dist/cjs/utils/popups/inlineRect.cjs +218 -0
  145. package/dist/cjs/utils/popups/popupStoreUtils.cjs +379 -0
  146. package/dist/cjs/utils/popups/popupTriggerMap.cjs +76 -0
  147. package/dist/cjs/utils/popups/store.cjs +118 -0
  148. package/dist/cjs/utils/popups/useTriggerFocusGuards.cjs +72 -0
  149. package/dist/cjs/utils/resolveAriaLabelledBy.cjs +35 -0
  150. package/dist/cjs/utils/resolveClassName.cjs +30 -0
  151. package/dist/cjs/utils/resolveRef.cjs +33 -0
  152. package/dist/cjs/utils/resolveStyle.cjs +30 -0
  153. package/dist/cjs/utils/serializeValue.cjs +40 -0
  154. package/dist/cjs/utils/slider/asc.cjs +30 -0
  155. package/dist/cjs/utils/slider/getMidpoint.cjs +34 -0
  156. package/dist/cjs/utils/slider/getPushedThumbValues.cjs +73 -0
  157. package/dist/cjs/utils/slider/getSliderValue.cjs +42 -0
  158. package/dist/cjs/utils/slider/replaceArrayItemAtIndex.cjs +33 -0
  159. package/dist/cjs/utils/slider/resolveThumbCollision.cjs +155 -0
  160. package/dist/cjs/utils/slider/roundValueToStep.cjs +45 -0
  161. package/dist/cjs/utils/slider/validateMinimumDistance.cjs +40 -0
  162. package/dist/cjs/utils/slider/valueArrayToPercentages.cjs +36 -0
  163. package/dist/cjs/utils/store/ReactStore.cjs +135 -0
  164. package/dist/cjs/utils/store/Store.cjs +83 -0
  165. package/dist/cjs/utils/store/createSelector.cjs +74 -0
  166. package/dist/cjs/utils/store/useStore.cjs +51 -0
  167. package/dist/cjs/utils/stringifyLocale.cjs +36 -0
  168. package/dist/cjs/utils/useAnchorPositioning.cjs +421 -0
  169. package/dist/cjs/utils/useAnchoredPopupScrollLock.cjs +59 -0
  170. package/dist/cjs/utils/useAnimationFrame.cjs +93 -0
  171. package/dist/cjs/utils/useAnimationsFinished.cjs +98 -0
  172. package/dist/cjs/utils/useBaseUiId.cjs +36 -0
  173. package/dist/cjs/utils/useButton.cjs +177 -0
  174. package/dist/cjs/utils/useCheckboxGroupParent.cjs +114 -0
  175. package/dist/cjs/utils/useControlled.cjs +47 -0
  176. package/dist/cjs/utils/useEnhancedClickHandler.cjs +60 -0
  177. package/dist/cjs/utils/useFocusableWhenDisabled.cjs +77 -0
  178. package/dist/cjs/utils/useForcedRerendering.cjs +35 -0
  179. package/dist/cjs/utils/useIsHydrating.cjs +44 -0
  180. package/dist/cjs/utils/useMixedToggleClickHandler.cjs +66 -0
  181. package/dist/cjs/utils/useOnFirstRender.cjs +35 -0
  182. package/dist/cjs/utils/useOnMount.cjs +36 -0
  183. package/dist/cjs/utils/useOpenChangeComplete.cjs +57 -0
  184. package/dist/cjs/utils/useOpenInteractionType.cjs +69 -0
  185. package/dist/cjs/utils/usePopupAutoResize.cjs +191 -0
  186. package/dist/cjs/utils/usePopupViewport.cjs +283 -0
  187. package/dist/cjs/utils/usePositioner.cjs +53 -0
  188. package/dist/cjs/utils/usePressAndHold.cjs +51 -0
  189. package/dist/cjs/utils/usePreviousValue.cjs +47 -0
  190. package/dist/cjs/utils/useRefWithInit.cjs +41 -0
  191. package/dist/cjs/utils/useRegisteredLabelId.cjs +48 -0
  192. package/dist/cjs/utils/useRenderElement.cjs +106 -0
  193. package/dist/cjs/utils/useScrollLock.cjs +232 -0
  194. package/dist/cjs/utils/useStableCallback.cjs +41 -0
  195. package/dist/cjs/utils/useTimeout.cjs +66 -0
  196. package/dist/cjs/utils/useTransitionStatus.cjs +116 -0
  197. package/dist/cjs/utils/useValueAsRef.cjs +43 -0
  198. package/dist/cjs/utils/useValueChanged.cjs +55 -0
  199. package/dist/cjs/utils/valueToPercent.cjs +30 -0
  200. package/dist/cjs/utils/visuallyHidden.cjs +49 -0
  201. package/package.json +20 -8
@@ -0,0 +1,632 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var preview_card_exports = {};
20
+ __export(preview_card_exports, {
21
+ CLOSE_DELAY: () => CLOSE_DELAY,
22
+ OPEN_DELAY: () => OPEN_DELAY,
23
+ PreviewCard: () => PreviewCard,
24
+ PreviewCardHandle: () => PreviewCardHandle,
25
+ PreviewCardStore: () => PreviewCardStore,
26
+ PreviewCardViewportCssVars: () => PreviewCardViewportCssVars,
27
+ createPreviewCardHandle: () => createPreviewCardHandle,
28
+ usePreviewCardPositionerContext: () => usePreviewCardPositionerContext,
29
+ usePreviewCardRootContext: () => usePreviewCardRootContext
30
+ });
31
+ module.exports = __toCommonJS(preview_card_exports);
32
+ var import_octane = require("octane");
33
+ var import_internal = require("./internal.cjs");
34
+ var import_useRenderElement = require("./utils/useRenderElement.cjs");
35
+ var import_mergeProps = require("./utils/mergeProps.cjs");
36
+ var import_useBaseUiId = require("./utils/useBaseUiId.cjs");
37
+ var import_createChangeEventDetails = require("./utils/createChangeEventDetails.cjs");
38
+ var import_empty = require("./utils/empty.cjs");
39
+ var import_ReactStore = require("./utils/store/ReactStore.cjs");
40
+ var import_createSelector = require("./utils/store/createSelector.cjs");
41
+ var import_useStableCallback = require("./utils/useStableCallback.cjs");
42
+ var import_useDismiss = require("./utils/floating/useDismiss.cjs");
43
+ var import_useFocus = require("./utils/floating/useFocus.cjs");
44
+ var import_useHoverReferenceInteraction = require("./utils/floating/useHoverReferenceInteraction.cjs");
45
+ var import_useHoverFloatingInteraction = require("./utils/floating/useHoverFloatingInteraction.cjs");
46
+ var import_FloatingTree = require("./utils/floating/FloatingTree.cjs");
47
+ var import_FloatingPortalLite = require("./utils/FloatingPortalLite.cjs");
48
+ var import_useAnchorPositioning = require("./utils/useAnchorPositioning.cjs");
49
+ var import_usePositioner = require("./utils/usePositioner.cjs");
50
+ var import_usePopupViewport = require("./utils/usePopupViewport.cjs");
51
+ var import_adaptiveOriginMiddleware = require("./utils/adaptiveOriginMiddleware.cjs");
52
+ var import_useOpenChangeComplete = require("./utils/useOpenChangeComplete.cjs");
53
+ var import_getDisabledMountTransitionStyles = require("./utils/getDisabledMountTransitionStyles.cjs");
54
+ var import_constants = require("./utils/constants.cjs");
55
+ var import_popupStateMapping = require("./utils/popupStateMapping.cjs");
56
+ var import_useTransitionStatus = require("./utils/useTransitionStatus.cjs");
57
+ var import_popups = require("./utils/popups/index.cjs");
58
+ var import_popupTriggerMap = require("./utils/popups/popupTriggerMap.cjs");
59
+ const OPEN_DELAY = 600;
60
+ const CLOSE_DELAY = 300;
61
+ const PreviewCardViewportCssVars = {
62
+ popupWidth: "--popup-width",
63
+ popupHeight: "--popup-height"
64
+ };
65
+ const previewCardSelectors = {
66
+ ...import_popups.popupStoreSelectors,
67
+ instantType: (0, import_createSelector.createSelector)((state) => state.instantType),
68
+ hasViewport: (0, import_createSelector.createSelector)((state) => state.hasViewport)
69
+ };
70
+ function createInitialPreviewCardState() {
71
+ return {
72
+ ...(0, import_popups.createInitialPopupStoreState)(),
73
+ instantType: void 0,
74
+ hasViewport: false
75
+ };
76
+ }
77
+ class PreviewCardStore extends import_ReactStore.ReactStore {
78
+ constructor(initialState, floatingId, nested = false) {
79
+ const triggerElements = new import_popupTriggerMap.PopupTriggerMap();
80
+ const state = { ...createInitialPreviewCardState(), ...initialState };
81
+ state.floatingRootContext = (0, import_popups.createPopupFloatingRootContext)(triggerElements, floatingId, nested);
82
+ super(
83
+ state,
84
+ {
85
+ popupRef: { current: null },
86
+ onOpenChange: void 0,
87
+ onOpenChangeComplete: void 0,
88
+ triggerElements,
89
+ closeDelayRef: { current: CLOSE_DELAY },
90
+ inlineRectCoordsRef: { current: void 0 }
91
+ },
92
+ previewCardSelectors
93
+ );
94
+ }
95
+ setOpen = (nextOpen, eventDetails) => {
96
+ const { inlineRectCoordsRef } = this.context;
97
+ (0, import_popups.applyPopupOpenChange)(this, nextOpen, eventDetails, {
98
+ onBeforeDispatch() {
99
+ const event = eventDetails.event;
100
+ if (nextOpen && eventDetails.reason === import_createChangeEventDetails.REASONS.triggerHover && eventDetails.trigger && event && "clientX" in event && "clientY" in event && inlineRectCoordsRef.current?.element !== eventDetails.trigger) {
101
+ (0, import_popups.updateInlineRectCoords)(
102
+ inlineRectCoordsRef,
103
+ eventDetails.trigger,
104
+ event.clientX,
105
+ event.clientY
106
+ );
107
+ }
108
+ }
109
+ });
110
+ };
111
+ static useStore(externalStore, initialState, slot) {
112
+ return (0, import_popups.usePopupStore)(
113
+ externalStore,
114
+ (floatingId, nested) => new PreviewCardStore(initialState, floatingId, nested),
115
+ true,
116
+ slot
117
+ ).store;
118
+ }
119
+ }
120
+ class PreviewCardHandle {
121
+ store;
122
+ constructor(store) {
123
+ this.store = store ?? new PreviewCardStore();
124
+ }
125
+ open(triggerId) {
126
+ const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
127
+ if (triggerId && !triggerElement) {
128
+ throw new Error(`Base UI: PreviewCardHandle.open: No trigger found with id "${triggerId}".`);
129
+ }
130
+ this.store.setOpen(
131
+ true,
132
+ (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.imperativeAction, void 0, triggerElement)
133
+ );
134
+ }
135
+ close() {
136
+ this.store.setOpen(
137
+ false,
138
+ (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.imperativeAction, void 0, void 0)
139
+ );
140
+ }
141
+ get isOpen() {
142
+ return this.store.select("open");
143
+ }
144
+ }
145
+ function createPreviewCardHandle() {
146
+ return new PreviewCardHandle();
147
+ }
148
+ const PreviewCardRootContext = (0, import_octane.createContext)(void 0);
149
+ function usePreviewCardRootContext(optional) {
150
+ const context = (0, import_octane.useContext)(PreviewCardRootContext);
151
+ if (context === void 0 && !optional) {
152
+ throw new Error(
153
+ "Base UI: PreviewCardRootContext is missing. PreviewCard parts must be placed within <PreviewCard.Root>."
154
+ );
155
+ }
156
+ return context;
157
+ }
158
+ const PreviewCardPortalContext = (0, import_octane.createContext)(void 0);
159
+ function usePreviewCardPortalContext() {
160
+ const value = (0, import_octane.useContext)(PreviewCardPortalContext);
161
+ if (value === void 0) {
162
+ throw new Error("Base UI: <PreviewCard.Portal> is missing.");
163
+ }
164
+ return value;
165
+ }
166
+ const PreviewCardPositionerContext = (0, import_octane.createContext)(
167
+ void 0
168
+ );
169
+ function usePreviewCardPositionerContext() {
170
+ const context = (0, import_octane.useContext)(PreviewCardPositionerContext);
171
+ if (!context) {
172
+ throw new Error(
173
+ "Base UI: PreviewCardPositionerContext is missing. PreviewCardPositioner parts must be placed within <PreviewCard.Positioner>."
174
+ );
175
+ }
176
+ return context;
177
+ }
178
+ function PreviewCardInteractions(props) {
179
+ const slot = (0, import_internal.S)("PreviewCardInteractions");
180
+ const { store } = props;
181
+ const floatingRootContext = store.useState("floatingRootContext", (0, import_internal.subSlot)(slot, "frc"));
182
+ const dismiss = (0, import_useDismiss.useDismiss)(floatingRootContext, {}, (0, import_internal.subSlot)(slot, "dismiss"));
183
+ const activeTriggerProps = dismiss.reference ?? import_empty.EMPTY_OBJECT;
184
+ const inactiveTriggerProps = dismiss.trigger ?? import_empty.EMPTY_OBJECT;
185
+ const popupProps = (0, import_octane.useMemo)(
186
+ () => (0, import_mergeProps.mergeProps)(import_popups.FOCUSABLE_POPUP_PROPS, dismiss.floating),
187
+ [dismiss.floating],
188
+ (0, import_internal.subSlot)(slot, "pp")
189
+ );
190
+ (0, import_popups.usePopupInteractionProps)(
191
+ store,
192
+ { activeTriggerProps, inactiveTriggerProps, popupProps },
193
+ (0, import_internal.subSlot)(slot, "pip")
194
+ );
195
+ return null;
196
+ }
197
+ function PreviewCardRootComponent(props) {
198
+ const slot = (0, import_internal.S)("PreviewCardRoot");
199
+ const {
200
+ open: openProp,
201
+ defaultOpen = false,
202
+ onOpenChange,
203
+ onOpenChangeComplete,
204
+ actionsRef,
205
+ handle,
206
+ triggerId: triggerIdProp,
207
+ defaultTriggerId: defaultTriggerIdProp = null,
208
+ children
209
+ } = props;
210
+ const store = PreviewCardStore.useStore(
211
+ handle?.store,
212
+ {
213
+ open: defaultOpen,
214
+ openProp,
215
+ activeTriggerId: defaultTriggerIdProp,
216
+ triggerIdProp
217
+ },
218
+ (0, import_internal.subSlot)(slot, "store")
219
+ );
220
+ (0, import_popups.useInitialOpenSync)(store, openProp, defaultOpen, defaultTriggerIdProp, (0, import_internal.subSlot)(slot, "ios"));
221
+ store.useControlledProp("openProp", openProp, (0, import_internal.subSlot)(slot, "cp:open"));
222
+ store.useControlledProp("triggerIdProp", triggerIdProp, (0, import_internal.subSlot)(slot, "cp:trigger"));
223
+ store.useContextCallback("onOpenChange", onOpenChange, (0, import_internal.subSlot)(slot, "cb:open"));
224
+ store.useContextCallback(
225
+ "onOpenChangeComplete",
226
+ onOpenChangeComplete,
227
+ (0, import_internal.subSlot)(slot, "cb:complete")
228
+ );
229
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
230
+ const activeTriggerId = store.useState("activeTriggerId", (0, import_internal.subSlot)(slot, "atid"));
231
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
232
+ const payload = store.useState("payload", (0, import_internal.subSlot)(slot, "payload"));
233
+ (0, import_popups.useImplicitActiveTrigger)(store, { closeOnActiveTriggerUnmount: true }, (0, import_internal.subSlot)(slot, "implicit"));
234
+ const { forceUnmount } = (0, import_popups.useOpenStateTransitions)(
235
+ open,
236
+ store,
237
+ () => {
238
+ store.context.inlineRectCoordsRef.current = void 0;
239
+ },
240
+ (0, import_internal.subSlot)(slot, "transitions")
241
+ );
242
+ (0, import_octane.useLayoutEffect)(
243
+ () => {
244
+ if (open && activeTriggerId == null) {
245
+ store.set("payload", void 0);
246
+ }
247
+ },
248
+ [store, activeTriggerId, open],
249
+ (0, import_internal.subSlot)(slot, "l:payload")
250
+ );
251
+ const handleImperativeClose = (0, import_octane.useCallback)(
252
+ () => {
253
+ store.setOpen(false, (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.imperativeAction));
254
+ },
255
+ [store],
256
+ (0, import_internal.subSlot)(slot, "close")
257
+ );
258
+ (0, import_octane.useImperativeHandle)(
259
+ actionsRef,
260
+ () => ({ unmount: forceUnmount, close: handleImperativeClose }),
261
+ [forceUnmount, handleImperativeClose],
262
+ (0, import_internal.subSlot)(slot, "imp")
263
+ );
264
+ const shouldRenderInteractions = open || mounted;
265
+ const resolvedChildren = typeof children === "function" && !(0, import_octane.isChildrenBlock)(children) ? children({ payload }) : children;
266
+ const content = [
267
+ shouldRenderInteractions ? (0, import_octane.createElement)(PreviewCardInteractions, { key: "interactions", store }) : null,
268
+ (0, import_octane.createElement)(import_octane.Fragment, { key: "children", children: resolvedChildren })
269
+ ];
270
+ return (0, import_octane.createElement)(PreviewCardRootContext.Provider, { value: store, children: content });
271
+ }
272
+ function PreviewCardRoot(props) {
273
+ if (usePreviewCardRootContext(true)) {
274
+ return (0, import_octane.createElement)(PreviewCardRootComponent, props);
275
+ }
276
+ return (0, import_octane.createElement)(import_FloatingTree.FloatingTree, {
277
+ children: (0, import_octane.createElement)(PreviewCardRootComponent, props)
278
+ });
279
+ }
280
+ function PreviewCardTrigger(componentProps) {
281
+ const slot = (0, import_internal.S)("PreviewCardTrigger");
282
+ const {
283
+ render,
284
+ className,
285
+ delay,
286
+ closeDelay,
287
+ id: idProp,
288
+ payload,
289
+ handle,
290
+ style,
291
+ ref,
292
+ ...elementProps
293
+ } = componentProps;
294
+ const rootContext = usePreviewCardRootContext(true);
295
+ const store = handle?.store ?? rootContext;
296
+ if (!store) {
297
+ throw new Error(
298
+ "Base UI: <PreviewCard.Trigger> must be either used within a <PreviewCard.Root> component or provided with a handle."
299
+ );
300
+ }
301
+ const thisTriggerId = (0, import_useBaseUiId.useBaseUiId)(idProp, (0, import_internal.subSlot)(slot, "id"));
302
+ const isTriggerActive = store.useState("isTriggerActive", (0, import_internal.subSlot)(slot, "ita"), thisTriggerId);
303
+ const isOpenedByThisTrigger = store.useState(
304
+ "isOpenedByTrigger",
305
+ (0, import_internal.subSlot)(slot, "obt"),
306
+ thisTriggerId
307
+ );
308
+ const floatingRootContext = store.useState("floatingRootContext", (0, import_internal.subSlot)(slot, "frc"));
309
+ const inlineRectCoordsRef = store.context.inlineRectCoordsRef;
310
+ const triggerElementRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "trigEl"));
311
+ const delayWithDefault = delay ?? OPEN_DELAY;
312
+ const closeDelayWithDefault = closeDelay ?? CLOSE_DELAY;
313
+ const { registerTrigger, isMountedByThisTrigger } = (0, import_popups.useTriggerDataForwarding)(
314
+ thisTriggerId,
315
+ triggerElementRef,
316
+ store,
317
+ { payload },
318
+ (0, import_internal.subSlot)(slot, "tdf")
319
+ );
320
+ (0, import_octane.useLayoutEffect)(
321
+ () => {
322
+ if (isMountedByThisTrigger) {
323
+ store.context.closeDelayRef.current = closeDelayWithDefault;
324
+ }
325
+ },
326
+ [store, isMountedByThisTrigger, closeDelayWithDefault],
327
+ (0, import_internal.subSlot)(slot, "l:closeDelay")
328
+ );
329
+ const hoverProps = (0, import_useHoverReferenceInteraction.useHoverReferenceInteraction)(
330
+ floatingRootContext,
331
+ {
332
+ mouseOnly: true,
333
+ move: false,
334
+ handleClose: (0, import_useHoverReferenceInteraction.safePolygon)(),
335
+ delay: () => ({ open: delayWithDefault, close: closeDelayWithDefault }),
336
+ triggerElementRef,
337
+ isActiveTrigger: isTriggerActive,
338
+ isClosing: () => store.select("transitionStatus") === "ending"
339
+ },
340
+ (0, import_internal.subSlot)(slot, "hover")
341
+ );
342
+ const focusProps = (0, import_useFocus.useFocus)(
343
+ floatingRootContext,
344
+ { delay: delayWithDefault },
345
+ (0, import_internal.subSlot)(slot, "focus")
346
+ );
347
+ const state = { open: isOpenedByThisTrigger };
348
+ const rootTriggerProps = store.useState(
349
+ "triggerProps",
350
+ (0, import_internal.subSlot)(slot, "tp"),
351
+ isMountedByThisTrigger
352
+ );
353
+ const inlineRectTriggerProps = (0, import_popups.getInlineRectTriggerProps)(
354
+ inlineRectCoordsRef,
355
+ isOpenedByThisTrigger
356
+ );
357
+ return (0, import_useRenderElement.useRenderElement)(
358
+ "a",
359
+ { render, className, style },
360
+ {
361
+ state,
362
+ ref: [ref, registerTrigger, triggerElementRef],
363
+ props: [
364
+ hoverProps,
365
+ focusProps.reference,
366
+ rootTriggerProps,
367
+ inlineRectTriggerProps,
368
+ { id: thisTriggerId },
369
+ elementProps
370
+ ],
371
+ stateAttributesMapping: import_popupStateMapping.triggerOpenStateMapping
372
+ },
373
+ (0, import_internal.subSlot)(slot, "re")
374
+ );
375
+ }
376
+ function PreviewCardPortal(props) {
377
+ const slot = (0, import_internal.S)("PreviewCardPortal");
378
+ const { keepMounted = false, ref, ...portalProps } = props;
379
+ const store = usePreviewCardRootContext();
380
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
381
+ if (!(mounted || keepMounted)) {
382
+ return null;
383
+ }
384
+ return (0, import_octane.createElement)(PreviewCardPortalContext.Provider, {
385
+ value: keepMounted,
386
+ children: (0, import_octane.createElement)(import_FloatingPortalLite.FloatingPortalLite, { ref, ...portalProps })
387
+ });
388
+ }
389
+ function PreviewCardPositioner(componentProps) {
390
+ const slot = (0, import_internal.S)("PreviewCardPositioner");
391
+ const {
392
+ render,
393
+ className,
394
+ style,
395
+ anchor,
396
+ positionMethod = "absolute",
397
+ side = "bottom",
398
+ align = "center",
399
+ sideOffset = 0,
400
+ alignOffset = 0,
401
+ collisionBoundary = "clipping-ancestors",
402
+ collisionPadding = 5,
403
+ arrowPadding = 5,
404
+ sticky = false,
405
+ disableAnchorTracking = false,
406
+ collisionAvoidance = import_constants.POPUP_COLLISION_AVOIDANCE,
407
+ ref,
408
+ ...elementProps
409
+ } = componentProps;
410
+ const store = usePreviewCardRootContext();
411
+ const keepMounted = usePreviewCardPortalContext();
412
+ const nodeId = (0, import_FloatingTree.useFloatingNodeId)(void 0, (0, import_internal.subSlot)(slot, "nodeId"));
413
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
414
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
415
+ const floatingRootContext = store.useState("floatingRootContext", (0, import_internal.subSlot)(slot, "frc"));
416
+ const instantType = store.useState("instantType", (0, import_internal.subSlot)(slot, "instant"));
417
+ const transitionStatus = store.useState("transitionStatus", (0, import_internal.subSlot)(slot, "trans"));
418
+ const hasViewport = store.useState("hasViewport", (0, import_internal.subSlot)(slot, "viewport"));
419
+ const inlineRectCoordsRef = store.context.inlineRectCoordsRef;
420
+ const inlineMiddleware = (0, import_octane.useMemo)(
421
+ () => (0, import_popups.createInlineMiddleware)(inlineRectCoordsRef),
422
+ [inlineRectCoordsRef],
423
+ (0, import_internal.subSlot)(slot, "inline")
424
+ );
425
+ const positioning = (0, import_useAnchorPositioning.useAnchorPositioning)(
426
+ {
427
+ anchor,
428
+ floatingRootContext,
429
+ positionMethod,
430
+ mounted,
431
+ side,
432
+ sideOffset,
433
+ align,
434
+ alignOffset,
435
+ arrowPadding,
436
+ collisionBoundary,
437
+ collisionPadding,
438
+ sticky,
439
+ disableAnchorTracking,
440
+ keepMounted,
441
+ nodeId,
442
+ collisionAvoidance,
443
+ adaptiveOrigin: hasViewport ? import_adaptiveOriginMiddleware.adaptiveOrigin : void 0,
444
+ inline: inlineMiddleware
445
+ },
446
+ (0, import_internal.subSlot)(slot, "pos")
447
+ );
448
+ const updatePosition = positioning.update;
449
+ (0, import_octane.useLayoutEffect)(
450
+ () => {
451
+ if (open && mounted) {
452
+ updatePosition();
453
+ }
454
+ },
455
+ [open, mounted, updatePosition],
456
+ (0, import_internal.subSlot)(slot, "l:update")
457
+ );
458
+ const state = {
459
+ open,
460
+ side: positioning.side,
461
+ align: positioning.align,
462
+ anchorHidden: positioning.anchorHidden,
463
+ instant: instantType
464
+ };
465
+ const setPositionerElement = store.useStateSetter("positionerElement", (0, import_internal.subSlot)(slot, "spe"));
466
+ const element = (0, import_usePositioner.usePositioner)(
467
+ { render, className, style },
468
+ state,
469
+ {
470
+ styles: positioning.positionerStyles,
471
+ transitionStatus,
472
+ props: elementProps,
473
+ refs: [ref, setPositionerElement],
474
+ hidden: !mounted,
475
+ inert: !open
476
+ },
477
+ (0, import_internal.subSlot)(slot, "positioner")
478
+ );
479
+ return (0, import_octane.createElement)(PreviewCardPositionerContext.Provider, {
480
+ value: positioning,
481
+ children: (0, import_octane.createElement)(import_FloatingTree.FloatingNode, { id: nodeId, children: element })
482
+ });
483
+ }
484
+ const popupStateAttributesMapping = {
485
+ ...import_popupStateMapping.popupStateMapping,
486
+ ...import_useTransitionStatus.transitionStatusMapping
487
+ };
488
+ function PreviewCardPopup(componentProps) {
489
+ const slot = (0, import_internal.S)("PreviewCardPopup");
490
+ const { className, render, style, ref, ...elementProps } = componentProps;
491
+ const store = usePreviewCardRootContext();
492
+ const { side, align } = usePreviewCardPositionerContext();
493
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
494
+ const instantType = store.useState("instantType", (0, import_internal.subSlot)(slot, "instant"));
495
+ const transitionStatus = store.useState("transitionStatus", (0, import_internal.subSlot)(slot, "trans"));
496
+ const popupProps = store.useState("popupProps", (0, import_internal.subSlot)(slot, "pp"));
497
+ const floatingContext = store.useState("floatingRootContext", (0, import_internal.subSlot)(slot, "frc"));
498
+ (0, import_useOpenChangeComplete.useOpenChangeComplete)(
499
+ {
500
+ open,
501
+ ref: store.context.popupRef,
502
+ onComplete() {
503
+ if (open) {
504
+ store.context.onOpenChangeComplete?.(true);
505
+ }
506
+ }
507
+ },
508
+ (0, import_internal.subSlot)(slot, "occ")
509
+ );
510
+ const getCloseDelay = (0, import_useStableCallback.useStableCallback)(
511
+ () => store.context.closeDelayRef.current,
512
+ (0, import_internal.subSlot)(slot, "gcd")
513
+ );
514
+ (0, import_useHoverFloatingInteraction.useHoverFloatingInteraction)(
515
+ floatingContext,
516
+ { closeDelay: getCloseDelay },
517
+ (0, import_internal.subSlot)(slot, "hoverPopup")
518
+ );
519
+ const setPopupElement = store.useStateSetter("popupElement", (0, import_internal.subSlot)(slot, "spe"));
520
+ const state = { open, side, align, instant: instantType, transitionStatus };
521
+ return (0, import_useRenderElement.useRenderElement)(
522
+ "div",
523
+ { render, className, style },
524
+ {
525
+ state,
526
+ ref: [ref, store.context.popupRef, setPopupElement],
527
+ props: [popupProps, (0, import_getDisabledMountTransitionStyles.getDisabledMountTransitionStyles)(transitionStatus), elementProps],
528
+ stateAttributesMapping: popupStateAttributesMapping
529
+ },
530
+ (0, import_internal.subSlot)(slot, "re")
531
+ );
532
+ }
533
+ function PreviewCardBackdrop(componentProps) {
534
+ const slot = (0, import_internal.S)("PreviewCardBackdrop");
535
+ const { render, className, style, ref, ...elementProps } = componentProps;
536
+ const store = usePreviewCardRootContext();
537
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
538
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "mounted"));
539
+ const transitionStatus = store.useState("transitionStatus", (0, import_internal.subSlot)(slot, "trans"));
540
+ const state = { open, transitionStatus };
541
+ return (0, import_useRenderElement.useRenderElement)(
542
+ "div",
543
+ { render, className, style },
544
+ {
545
+ state,
546
+ ref: [ref],
547
+ props: [
548
+ {
549
+ role: "presentation",
550
+ hidden: !mounted,
551
+ style: { pointerEvents: "none", userSelect: "none", WebkitUserSelect: "none" }
552
+ },
553
+ elementProps
554
+ ],
555
+ stateAttributesMapping: popupStateAttributesMapping
556
+ },
557
+ (0, import_internal.subSlot)(slot, "re")
558
+ );
559
+ }
560
+ function PreviewCardArrow(componentProps) {
561
+ const slot = (0, import_internal.S)("PreviewCardArrow");
562
+ const { render, className, style, ref, ...elementProps } = componentProps;
563
+ const store = usePreviewCardRootContext();
564
+ const { arrowRef, side, align, arrowUncentered, arrowStyles } = usePreviewCardPositionerContext();
565
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
566
+ const state = { open, side, align, uncentered: arrowUncentered };
567
+ return (0, import_useRenderElement.useRenderElement)(
568
+ "div",
569
+ { render, className, style },
570
+ {
571
+ state,
572
+ ref: [arrowRef, ref],
573
+ props: [{ style: arrowStyles, "aria-hidden": true }, elementProps],
574
+ stateAttributesMapping: import_popupStateMapping.popupStateMapping
575
+ },
576
+ (0, import_internal.subSlot)(slot, "re")
577
+ );
578
+ }
579
+ const viewportStateAttributesMapping = {
580
+ activationDirection: (value) => value ? { "data-activation-direction": value } : null
581
+ };
582
+ function PreviewCardViewport(componentProps) {
583
+ const slot = (0, import_internal.S)("PreviewCardViewport");
584
+ const { render, className, style, children, ref, ...elementProps } = componentProps;
585
+ const store = usePreviewCardRootContext();
586
+ const positioner = usePreviewCardPositionerContext();
587
+ const instantType = store.useState("instantType", (0, import_internal.subSlot)(slot, "instant"));
588
+ const { children: childrenToRender, state: viewportState } = (0, import_usePopupViewport.usePopupViewport)(
589
+ { store, side: positioner.side, cssVars: PreviewCardViewportCssVars, children },
590
+ (0, import_internal.subSlot)(slot, "vp")
591
+ );
592
+ const state = {
593
+ activationDirection: viewportState.activationDirection,
594
+ transitioning: viewportState.transitioning,
595
+ instant: instantType
596
+ };
597
+ return (0, import_useRenderElement.useRenderElement)(
598
+ "div",
599
+ { render, className, style },
600
+ {
601
+ state,
602
+ ref,
603
+ props: [elementProps, { children: childrenToRender }],
604
+ stateAttributesMapping: viewportStateAttributesMapping
605
+ },
606
+ (0, import_internal.subSlot)(slot, "re")
607
+ );
608
+ }
609
+ const PreviewCard = {
610
+ Root: PreviewCardRoot,
611
+ Trigger: PreviewCardTrigger,
612
+ Portal: PreviewCardPortal,
613
+ Positioner: PreviewCardPositioner,
614
+ Popup: PreviewCardPopup,
615
+ Backdrop: PreviewCardBackdrop,
616
+ Arrow: PreviewCardArrow,
617
+ Viewport: PreviewCardViewport,
618
+ createHandle: createPreviewCardHandle,
619
+ Handle: PreviewCardHandle
620
+ };
621
+ // Annotate the CommonJS export names for ESM import in node:
622
+ 0 && (module.exports = {
623
+ CLOSE_DELAY,
624
+ OPEN_DELAY,
625
+ PreviewCard,
626
+ PreviewCardHandle,
627
+ PreviewCardStore,
628
+ PreviewCardViewportCssVars,
629
+ createPreviewCardHandle,
630
+ usePreviewCardPositionerContext,
631
+ usePreviewCardRootContext
632
+ });