@octanejs/base-ui 0.1.30 → 0.1.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,35 @@
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 useOnFirstRender_exports = {};
20
+ __export(useOnFirstRender_exports, {
21
+ useOnFirstRender: () => useOnFirstRender
22
+ });
23
+ module.exports = __toCommonJS(useOnFirstRender_exports);
24
+ var import_octane = require("octane");
25
+ function useOnFirstRender(fn, slot) {
26
+ const ref = (0, import_octane.useRef)(true, slot);
27
+ if (ref.current) {
28
+ ref.current = false;
29
+ fn();
30
+ }
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ useOnFirstRender
35
+ });
@@ -0,0 +1,36 @@
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 useOnMount_exports = {};
20
+ __export(useOnMount_exports, {
21
+ useOnMount: () => useOnMount
22
+ });
23
+ module.exports = __toCommonJS(useOnMount_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ var import_empty = require("./empty.cjs");
27
+ function useOnMount(...args) {
28
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
29
+ const slot = slotArg ?? (0, import_internal.S)("useOnMount");
30
+ const fn = user[0];
31
+ (0, import_octane.useEffect)(fn, import_empty.EMPTY_ARRAY, (0, import_internal.subSlot)(slot, "e"));
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ useOnMount
36
+ });
@@ -0,0 +1,57 @@
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 useOpenChangeComplete_exports = {};
20
+ __export(useOpenChangeComplete_exports, {
21
+ useOpenChangeComplete: () => useOpenChangeComplete
22
+ });
23
+ module.exports = __toCommonJS(useOpenChangeComplete_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ var import_useStableCallback = require("./useStableCallback.cjs");
27
+ var import_useAnimationsFinished = require("./useAnimationsFinished.cjs");
28
+ function useOpenChangeComplete(...args) {
29
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
30
+ const slot = slotArg ?? (0, import_internal.S)("useOpenChangeComplete");
31
+ const {
32
+ enabled = true,
33
+ open,
34
+ ref,
35
+ onComplete: onCompleteParam
36
+ } = user[0];
37
+ const onComplete = (0, import_useStableCallback.useStableCallback)(onCompleteParam, (0, import_internal.subSlot)(slot, "oc"));
38
+ const runOnceAnimationsFinish = (0, import_useAnimationsFinished.useAnimationsFinished)(ref, open, false, (0, import_internal.subSlot)(slot, "raf"));
39
+ (0, import_octane.useEffect)(
40
+ () => {
41
+ if (!enabled) {
42
+ return void 0;
43
+ }
44
+ const abortController = new AbortController();
45
+ runOnceAnimationsFinish(onComplete, abortController.signal);
46
+ return () => {
47
+ abortController.abort();
48
+ };
49
+ },
50
+ [enabled, open, onComplete, runOnceAnimationsFinish],
51
+ (0, import_internal.subSlot)(slot, "e:run")
52
+ );
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ useOpenChangeComplete
57
+ });
@@ -0,0 +1,69 @@
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 useOpenInteractionType_exports = {};
20
+ __export(useOpenInteractionType_exports, {
21
+ useOpenInteractionType: () => useOpenInteractionType,
22
+ useOpenMethodTriggerProps: () => useOpenMethodTriggerProps
23
+ });
24
+ module.exports = __toCommonJS(useOpenInteractionType_exports);
25
+ var import_octane = require("octane");
26
+ var import_internal = require("../internal.cjs");
27
+ var import_useStableCallback = require("./useStableCallback.cjs");
28
+ var import_useEnhancedClickHandler = require("./useEnhancedClickHandler.cjs");
29
+ var import_useValueChanged = require("./useValueChanged.cjs");
30
+ var import_platform = require("./platform.cjs");
31
+ function useOpenMethodTriggerProps(open, setOpenMethod, slot) {
32
+ const handleTriggerClick = (0, import_useStableCallback.useStableCallback)(
33
+ (_, interactionType) => {
34
+ const isOpen = typeof open === "function" ? open() : open;
35
+ if (!isOpen) {
36
+ setOpenMethod(interactionType || (import_platform.platform.os.ios ? "touch" : ""));
37
+ }
38
+ },
39
+ (0, import_internal.subSlot)(slot, "h")
40
+ );
41
+ const { onClick, onPointerDown } = (0, import_useEnhancedClickHandler.useEnhancedClickHandler)(
42
+ handleTriggerClick,
43
+ (0, import_internal.subSlot)(slot, "ech")
44
+ );
45
+ return (0, import_octane.useMemo)(() => ({ onClick, onPointerDown }), [onClick, onPointerDown], (0, import_internal.subSlot)(slot, "m"));
46
+ }
47
+ function useOpenInteractionType(open, slot) {
48
+ const [openMethod, setOpenMethod] = (0, import_octane.useState)(null, (0, import_internal.subSlot)(slot, "s"));
49
+ const triggerProps = useOpenMethodTriggerProps(open, setOpenMethod, (0, import_internal.subSlot)(slot, "tp"));
50
+ (0, import_useValueChanged.useValueChanged)(
51
+ open,
52
+ (previousOpen) => {
53
+ if (previousOpen && !open) {
54
+ setOpenMethod(null);
55
+ }
56
+ },
57
+ (0, import_internal.subSlot)(slot, "vc")
58
+ );
59
+ return (0, import_octane.useMemo)(
60
+ () => ({ openMethod, triggerProps }),
61
+ [openMethod, triggerProps],
62
+ (0, import_internal.subSlot)(slot, "r")
63
+ );
64
+ }
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ useOpenInteractionType,
68
+ useOpenMethodTriggerProps
69
+ });
@@ -0,0 +1,191 @@
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 usePopupAutoResize_exports = {};
20
+ __export(usePopupAutoResize_exports, {
21
+ usePopupAutoResize: () => usePopupAutoResize
22
+ });
23
+ module.exports = __toCommonJS(usePopupAutoResize_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ var import_empty = require("./empty.cjs");
27
+ var import_useAnimationFrame = require("./useAnimationFrame.cjs");
28
+ var import_useAnimationsFinished = require("./useAnimationsFinished.cjs");
29
+ var import_useStableCallback = require("./useStableCallback.cjs");
30
+ var import_getCssDimensions = require("./getCssDimensions.cjs");
31
+ function overrideElementStyle(element, property, value) {
32
+ const originalValue = element.style.getPropertyValue(property);
33
+ element.style.setProperty(property, value);
34
+ return () => {
35
+ element.style.setProperty(property, originalValue);
36
+ };
37
+ }
38
+ function applyElementStyles(element, styles) {
39
+ const restorers = [];
40
+ for (const [key, value] of Object.entries(styles)) {
41
+ restorers.push(overrideElementStyle(element, key, value));
42
+ }
43
+ return restorers.length ? () => {
44
+ restorers.forEach((restore) => restore());
45
+ } : import_empty.NOOP;
46
+ }
47
+ function setPopupCssSize(popupElement, size) {
48
+ const width = size === "auto" ? "auto" : `${size.width}px`;
49
+ const height = size === "auto" ? "auto" : `${size.height}px`;
50
+ popupElement.style.setProperty("--popup-width", width);
51
+ popupElement.style.setProperty("--popup-height", height);
52
+ }
53
+ function setPositionerCssSize(positionerElement, size) {
54
+ const width = size === "max-content" ? "max-content" : `${size.width}px`;
55
+ const height = size === "max-content" ? "max-content" : `${size.height}px`;
56
+ positionerElement.style.setProperty("--positioner-width", width);
57
+ positionerElement.style.setProperty("--positioner-height", height);
58
+ }
59
+ function usePopupAutoResize(...args) {
60
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
61
+ const slot = slotArg ?? (0, import_internal.S)("usePopupAutoResize");
62
+ const parameters = user[0];
63
+ const {
64
+ popupElement,
65
+ positionerElement,
66
+ content,
67
+ mounted,
68
+ onMeasureLayout: onMeasureLayoutParam,
69
+ onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
70
+ side,
71
+ direction
72
+ } = parameters;
73
+ const runOnceAnimationsFinish = (0, import_useAnimationsFinished.useAnimationsFinished)(
74
+ popupElement,
75
+ true,
76
+ false,
77
+ (0, import_internal.subSlot)(slot, "anim")
78
+ );
79
+ const animationFrame = (0, import_useAnimationFrame.useAnimationFrame)((0, import_internal.subSlot)(slot, "frame"));
80
+ const committedDimensionsRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "dims"));
81
+ const isInitialRenderRef = (0, import_octane.useRef)(true, (0, import_internal.subSlot)(slot, "init"));
82
+ const restoreAnchoringStylesRef = (0, import_octane.useRef)(import_empty.NOOP, (0, import_internal.subSlot)(slot, "restore"));
83
+ const onMeasureLayout = (0, import_useStableCallback.useStableCallback)(onMeasureLayoutParam, (0, import_internal.subSlot)(slot, "oml"));
84
+ const onMeasureLayoutComplete = (0, import_useStableCallback.useStableCallback)(
85
+ onMeasureLayoutCompleteParam,
86
+ (0, import_internal.subSlot)(slot, "omlc")
87
+ );
88
+ const anchoringStyles = (0, import_octane.useMemo)(
89
+ () => {
90
+ let isOriginSide = side === "top";
91
+ let isPhysicalLeft = side === "left";
92
+ if (direction === "rtl") {
93
+ isOriginSide = isOriginSide || side === "inline-end";
94
+ isPhysicalLeft = isPhysicalLeft || side === "inline-end";
95
+ } else {
96
+ isOriginSide = isOriginSide || side === "inline-start";
97
+ isPhysicalLeft = isPhysicalLeft || side === "inline-start";
98
+ }
99
+ return isOriginSide ? {
100
+ position: "absolute",
101
+ [side === "top" ? "bottom" : "top"]: "0",
102
+ [isPhysicalLeft ? "right" : "left"]: "0"
103
+ } : import_empty.EMPTY_OBJECT;
104
+ },
105
+ [side, direction],
106
+ (0, import_internal.subSlot)(slot, "anchoring")
107
+ );
108
+ (0, import_octane.useLayoutEffect)(
109
+ () => {
110
+ if (!mounted) {
111
+ restoreAnchoringStylesRef.current = import_empty.NOOP;
112
+ isInitialRenderRef.current = true;
113
+ committedDimensionsRef.current = null;
114
+ return void 0;
115
+ }
116
+ if (!popupElement || !positionerElement) {
117
+ return void 0;
118
+ }
119
+ restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
120
+ setPopupCssSize(popupElement, "auto");
121
+ const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
122
+ const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
123
+ const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
124
+ const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
125
+ "--available-width": "max-content",
126
+ "--available-height": "max-content"
127
+ });
128
+ function restoreMeasurementOverrides() {
129
+ restorePopupPosition();
130
+ restorePopupTransform();
131
+ restorePositionerAvailableSize();
132
+ }
133
+ function restoreMeasurementOverridesIncludingScale() {
134
+ restoreMeasurementOverrides();
135
+ restorePopupScale();
136
+ }
137
+ onMeasureLayout?.();
138
+ if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
139
+ setPositionerCssSize(positionerElement, "max-content");
140
+ const dimensions = (0, import_getCssDimensions.getCssDimensions)(popupElement);
141
+ committedDimensionsRef.current = dimensions;
142
+ setPositionerCssSize(positionerElement, dimensions);
143
+ restoreMeasurementOverridesIncludingScale();
144
+ onMeasureLayoutComplete?.(null, dimensions);
145
+ isInitialRenderRef.current = false;
146
+ return () => {
147
+ restoreAnchoringStylesRef.current();
148
+ restoreAnchoringStylesRef.current = import_empty.NOOP;
149
+ };
150
+ }
151
+ setPositionerCssSize(positionerElement, "max-content");
152
+ const previousDimensions = committedDimensionsRef.current;
153
+ const newDimensions = (0, import_getCssDimensions.getCssDimensions)(popupElement);
154
+ committedDimensionsRef.current = newDimensions;
155
+ setPopupCssSize(popupElement, previousDimensions);
156
+ restoreMeasurementOverridesIncludingScale();
157
+ onMeasureLayoutComplete?.(previousDimensions, newDimensions);
158
+ setPositionerCssSize(positionerElement, newDimensions);
159
+ const abortController = new AbortController();
160
+ animationFrame.request(() => {
161
+ setPopupCssSize(popupElement, newDimensions);
162
+ runOnceAnimationsFinish(() => {
163
+ popupElement.style.setProperty("--popup-width", "auto");
164
+ popupElement.style.setProperty("--popup-height", "auto");
165
+ }, abortController.signal);
166
+ });
167
+ return () => {
168
+ abortController.abort();
169
+ animationFrame.cancel();
170
+ restoreAnchoringStylesRef.current();
171
+ restoreAnchoringStylesRef.current = import_empty.NOOP;
172
+ };
173
+ },
174
+ [
175
+ content,
176
+ popupElement,
177
+ positionerElement,
178
+ runOnceAnimationsFinish,
179
+ animationFrame,
180
+ mounted,
181
+ onMeasureLayout,
182
+ onMeasureLayoutComplete,
183
+ anchoringStyles
184
+ ],
185
+ (0, import_internal.subSlot)(slot, "l:resize")
186
+ );
187
+ }
188
+ // Annotate the CommonJS export names for ESM import in node:
189
+ 0 && (module.exports = {
190
+ usePopupAutoResize
191
+ });
@@ -0,0 +1,283 @@
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 usePopupViewport_exports = {};
20
+ __export(usePopupViewport_exports, {
21
+ usePopupViewport: () => usePopupViewport
22
+ });
23
+ module.exports = __toCommonJS(usePopupViewport_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ var import_inertValue = require("./inertValue.cjs");
27
+ var import_owner = require("./owner.cjs");
28
+ var import_useAnimationFrame = require("./useAnimationFrame.cjs");
29
+ var import_useAnimationsFinished = require("./useAnimationsFinished.cjs");
30
+ var import_usePreviousValue = require("./usePreviousValue.cjs");
31
+ var import_useStableCallback = require("./useStableCallback.cjs");
32
+ var import_usePopupAutoResize = require("./usePopupAutoResize.cjs");
33
+ var import_DirectionContext = require("./DirectionContext.cjs");
34
+ function getActivationDirection(offset) {
35
+ if (!offset) {
36
+ return void 0;
37
+ }
38
+ return `${getValueWithTolerance(offset.horizontal, 5, "right", "left")} ${getValueWithTolerance(
39
+ offset.vertical,
40
+ 5,
41
+ "down",
42
+ "up"
43
+ )}`;
44
+ }
45
+ function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
46
+ if (value > tolerance) {
47
+ return positiveLabel;
48
+ }
49
+ if (value < -tolerance) {
50
+ return negativeLabel;
51
+ }
52
+ return "";
53
+ }
54
+ function calculateRelativePosition(from, to) {
55
+ const fromRect = from.getBoundingClientRect();
56
+ const toRect = to.getBoundingClientRect();
57
+ const fromCenter = {
58
+ x: fromRect.left + fromRect.width / 2,
59
+ y: fromRect.top + fromRect.height / 2
60
+ };
61
+ const toCenter = { x: toRect.left + toRect.width / 2, y: toRect.top + toRect.height / 2 };
62
+ return { horizontal: toCenter.x - fromCenter.x, vertical: toCenter.y - fromCenter.y };
63
+ }
64
+ function usePopupContentKey(activeTriggerId, payload, slot) {
65
+ const [contentKey, setContentKey] = (0, import_octane.useState)(0, (0, import_internal.subSlot)(slot, "ck"));
66
+ const previousActiveTriggerIdRef = (0, import_octane.useRef)(activeTriggerId, (0, import_internal.subSlot)(slot, "prevId"));
67
+ const previousPayloadRef = (0, import_octane.useRef)(payload, (0, import_internal.subSlot)(slot, "prevPayload"));
68
+ const pendingPayloadUpdateRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "pending"));
69
+ (0, import_octane.useLayoutEffect)(
70
+ () => {
71
+ const previousActiveTriggerId = previousActiveTriggerIdRef.current;
72
+ const previousPayload = previousPayloadRef.current;
73
+ const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
74
+ const payloadChanged = payload !== previousPayload;
75
+ if (triggerIdChanged) {
76
+ setContentKey((k) => k + 1);
77
+ pendingPayloadUpdateRef.current = !payloadChanged;
78
+ } else if (pendingPayloadUpdateRef.current && payloadChanged) {
79
+ setContentKey((k) => k + 1);
80
+ pendingPayloadUpdateRef.current = false;
81
+ }
82
+ previousActiveTriggerIdRef.current = activeTriggerId;
83
+ previousPayloadRef.current = payload;
84
+ },
85
+ [activeTriggerId, payload],
86
+ (0, import_internal.subSlot)(slot, "l:key")
87
+ );
88
+ return `${activeTriggerId ?? "current"}-${contentKey}`;
89
+ }
90
+ function usePopupViewport(...args) {
91
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
92
+ const slot = slotArg ?? (0, import_internal.S)("usePopupViewport");
93
+ const parameters = user[0];
94
+ const { store, side, cssVars, children } = parameters;
95
+ const direction = (0, import_DirectionContext.useDirection)();
96
+ const activeTrigger = store.useState("activeTriggerElement", (0, import_internal.subSlot)(slot, "s:trigger"));
97
+ const activeTriggerId = store.useState("activeTriggerId", (0, import_internal.subSlot)(slot, "s:triggerId"));
98
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "s:open"));
99
+ const payload = store.useState("payload", (0, import_internal.subSlot)(slot, "s:payload"));
100
+ const mounted = store.useState("mounted", (0, import_internal.subSlot)(slot, "s:mounted"));
101
+ const popupElement = store.useState("popupElement", (0, import_internal.subSlot)(slot, "s:popup"));
102
+ const positionerElement = store.useState("positionerElement", (0, import_internal.subSlot)(slot, "s:positioner"));
103
+ const previousActiveTrigger = (0, import_usePreviousValue.usePreviousValue)(
104
+ open ? activeTrigger : null,
105
+ (0, import_internal.subSlot)(slot, "prevTrigger")
106
+ );
107
+ const currentContentKey = usePopupContentKey(
108
+ activeTriggerId,
109
+ payload,
110
+ (0, import_internal.subSlot)(slot, "contentKey")
111
+ );
112
+ const capturedNodeRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "captured"));
113
+ const [previousContentNode, setPreviousContentNode] = (0, import_octane.useState)(
114
+ null,
115
+ (0, import_internal.subSlot)(slot, "prevNode")
116
+ );
117
+ const [newTriggerOffset, setNewTriggerOffset] = (0, import_octane.useState)(
118
+ null,
119
+ (0, import_internal.subSlot)(slot, "offset")
120
+ );
121
+ const currentContainerRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "curRef"));
122
+ const previousContainerRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "prevRef"));
123
+ const onAnimationsFinished = (0, import_useAnimationsFinished.useAnimationsFinished)(
124
+ currentContainerRef,
125
+ true,
126
+ false,
127
+ (0, import_internal.subSlot)(slot, "anim")
128
+ );
129
+ const cleanupFrame = (0, import_useAnimationFrame.useAnimationFrame)((0, import_internal.subSlot)(slot, "frame"));
130
+ const [previousContentDimensions, setPreviousContentDimensions] = (0, import_octane.useState)(
131
+ null,
132
+ (0, import_internal.subSlot)(slot, "prevDims")
133
+ );
134
+ const [showStartingStyleAttribute, setShowStartingStyleAttribute] = (0, import_octane.useState)(
135
+ false,
136
+ (0, import_internal.subSlot)(slot, "starting")
137
+ );
138
+ (0, import_octane.useLayoutEffect)(
139
+ () => {
140
+ store.set("hasViewport", true);
141
+ return () => {
142
+ store.set("hasViewport", false);
143
+ };
144
+ },
145
+ [store],
146
+ (0, import_internal.subSlot)(slot, "l:hasViewport")
147
+ );
148
+ const handleMeasureLayout = (0, import_useStableCallback.useStableCallback)(
149
+ () => {
150
+ currentContainerRef.current?.style.setProperty("animation", "none");
151
+ currentContainerRef.current?.style.setProperty("transition", "none");
152
+ previousContainerRef.current?.style.setProperty("display", "none");
153
+ },
154
+ (0, import_internal.subSlot)(slot, "hml")
155
+ );
156
+ const handleMeasureLayoutComplete = (0, import_useStableCallback.useStableCallback)(
157
+ (previousDimensions) => {
158
+ currentContainerRef.current?.style.removeProperty("animation");
159
+ currentContainerRef.current?.style.removeProperty("transition");
160
+ previousContainerRef.current?.style.removeProperty("display");
161
+ if (previousDimensions) {
162
+ setPreviousContentDimensions(previousDimensions);
163
+ }
164
+ },
165
+ (0, import_internal.subSlot)(slot, "hmlc")
166
+ );
167
+ const lastHandledTriggerRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "lastTrigger"));
168
+ (0, import_octane.useLayoutEffect)(
169
+ () => {
170
+ if (!open || !mounted) {
171
+ lastHandledTriggerRef.current = null;
172
+ }
173
+ },
174
+ [open, mounted],
175
+ (0, import_internal.subSlot)(slot, "l:resetTrigger")
176
+ );
177
+ (0, import_octane.useLayoutEffect)(
178
+ () => {
179
+ if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
180
+ setPreviousContentNode(capturedNodeRef.current);
181
+ setShowStartingStyleAttribute(true);
182
+ setNewTriggerOffset(calculateRelativePosition(previousActiveTrigger, activeTrigger));
183
+ cleanupFrame.request(() => {
184
+ (0, import_octane.flushSync)(() => {
185
+ setShowStartingStyleAttribute(false);
186
+ });
187
+ onAnimationsFinished(() => {
188
+ setPreviousContentNode(null);
189
+ setPreviousContentDimensions(null);
190
+ capturedNodeRef.current = null;
191
+ });
192
+ });
193
+ lastHandledTriggerRef.current = activeTrigger;
194
+ }
195
+ },
196
+ [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame],
197
+ (0, import_internal.subSlot)(slot, "l:transition")
198
+ );
199
+ (0, import_octane.useLayoutEffect)(
200
+ () => {
201
+ const source = currentContainerRef.current;
202
+ if (!source) {
203
+ return;
204
+ }
205
+ const wrapper = (0, import_owner.ownerDocument)(source).createElement("div");
206
+ for (const child of Array.from(source.childNodes)) {
207
+ wrapper.appendChild(child.cloneNode(true));
208
+ }
209
+ capturedNodeRef.current = wrapper;
210
+ },
211
+ void 0,
212
+ (0, import_internal.subSlot)(slot, "l:capture")
213
+ );
214
+ const isTransitioning = previousContentNode != null;
215
+ let childrenToRender;
216
+ if (!isTransitioning) {
217
+ childrenToRender = (0, import_octane.createElement)("div", {
218
+ "data-current": true,
219
+ ref: currentContainerRef,
220
+ key: currentContentKey,
221
+ children
222
+ });
223
+ } else {
224
+ childrenToRender = (0, import_octane.createElement)(import_octane.Fragment, {
225
+ children: [
226
+ (0, import_octane.createElement)("div", {
227
+ "data-previous": true,
228
+ inert: (0, import_inertValue.inertValue)(true),
229
+ ref: previousContainerRef,
230
+ style: {
231
+ ...previousContentDimensions ? {
232
+ [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
233
+ [cssVars.popupHeight]: `${previousContentDimensions.height}px`
234
+ } : null,
235
+ position: "absolute"
236
+ },
237
+ key: "previous",
238
+ "data-ending-style": showStartingStyleAttribute ? void 0 : ""
239
+ }),
240
+ (0, import_octane.createElement)("div", {
241
+ "data-current": true,
242
+ ref: currentContainerRef,
243
+ key: currentContentKey,
244
+ "data-starting-style": showStartingStyleAttribute ? "" : void 0,
245
+ children
246
+ })
247
+ ]
248
+ });
249
+ }
250
+ (0, import_octane.useLayoutEffect)(
251
+ () => {
252
+ const container = previousContainerRef.current;
253
+ if (!container || !previousContentNode) {
254
+ return;
255
+ }
256
+ container.replaceChildren(...Array.from(previousContentNode.childNodes));
257
+ },
258
+ [previousContentNode],
259
+ (0, import_internal.subSlot)(slot, "l:populate")
260
+ );
261
+ (0, import_usePopupAutoResize.usePopupAutoResize)(
262
+ {
263
+ popupElement,
264
+ positionerElement,
265
+ mounted,
266
+ content: payload,
267
+ onMeasureLayout: handleMeasureLayout,
268
+ onMeasureLayoutComplete: handleMeasureLayoutComplete,
269
+ side,
270
+ direction
271
+ },
272
+ (0, import_internal.subSlot)(slot, "resize")
273
+ );
274
+ const state = {
275
+ activationDirection: getActivationDirection(newTriggerOffset),
276
+ transitioning: isTransitioning
277
+ };
278
+ return { children: childrenToRender, state };
279
+ }
280
+ // Annotate the CommonJS export names for ESM import in node:
281
+ 0 && (module.exports = {
282
+ usePopupViewport
283
+ });