@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,91 @@
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 useSyncedFloatingRootContext_exports = {};
20
+ __export(useSyncedFloatingRootContext_exports, {
21
+ useSyncedFloatingRootContext: () => useSyncedFloatingRootContext
22
+ });
23
+ module.exports = __toCommonJS(useSyncedFloatingRootContext_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../../internal.cjs");
26
+ var import_dom = require("../dom.cjs");
27
+ var import_FloatingRootStore = require("./FloatingRootStore.cjs");
28
+ function useSyncedFloatingRootContext(options, slot) {
29
+ const {
30
+ popupStore,
31
+ treatPopupAsFloatingElement = false,
32
+ floatingRootContext: floatingRootContextProp,
33
+ floatingId,
34
+ nested,
35
+ onOpenChange
36
+ } = options;
37
+ const open = popupStore.useState("open", (0, import_internal.subSlot)(slot, "open"));
38
+ const referenceElement = popupStore.useState("activeTriggerElement", (0, import_internal.subSlot)(slot, "ref"));
39
+ const floatingElement = popupStore.useState(
40
+ treatPopupAsFloatingElement ? "popupElement" : "positionerElement",
41
+ (0, import_internal.subSlot)(slot, "floating")
42
+ );
43
+ const triggerElements = popupStore.context.triggerElements;
44
+ const handleOpenChange = onOpenChange;
45
+ const internalStoreRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "store"));
46
+ if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
47
+ internalStoreRef.current = new import_FloatingRootStore.FloatingRootStore({
48
+ open,
49
+ transitionStatus: void 0,
50
+ referenceElement,
51
+ floatingElement,
52
+ triggerElements,
53
+ onOpenChange: handleOpenChange,
54
+ floatingId,
55
+ syncOnly: true,
56
+ nested
57
+ });
58
+ }
59
+ const store = floatingRootContextProp ?? internalStoreRef.current;
60
+ popupStore.useSyncedValue(
61
+ "floatingId",
62
+ floatingId,
63
+ (0, import_internal.subSlot)(slot, "syncId")
64
+ );
65
+ (0, import_octane.useLayoutEffect)(
66
+ () => {
67
+ const valuesToSync = {
68
+ open,
69
+ floatingId,
70
+ referenceElement,
71
+ floatingElement
72
+ };
73
+ if ((0, import_dom.isElement)(referenceElement)) {
74
+ valuesToSync.domReferenceElement = referenceElement;
75
+ }
76
+ if (store.state.positionReference === store.state.referenceElement) {
77
+ valuesToSync.positionReference = referenceElement;
78
+ }
79
+ store.update(valuesToSync);
80
+ },
81
+ [open, floatingId, referenceElement, floatingElement, store],
82
+ (0, import_internal.subSlot)(slot, "e:sync")
83
+ );
84
+ store.context.onOpenChange = handleOpenChange;
85
+ store.context.nested = nested;
86
+ return store;
87
+ }
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ useSyncedFloatingRootContext
91
+ });
@@ -0,0 +1,187 @@
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 useTypeahead_exports = {};
20
+ __export(useTypeahead_exports, {
21
+ useTypeahead: () => useTypeahead
22
+ });
23
+ module.exports = __toCommonJS(useTypeahead_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../../internal.cjs");
26
+ var import_empty = require("../empty.cjs");
27
+ var import_useStableCallback = require("../useStableCallback.cjs");
28
+ var import_useTimeout = require("../useTimeout.cjs");
29
+ var import_list_utils = require("../composite/list-utils.cjs");
30
+ var import_composite = require("./composite.cjs");
31
+ var import_element = require("./element.cjs");
32
+ function useTypeahead(...args) {
33
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
34
+ const slot = slotArg ?? (0, import_internal.S)("useTypeahead");
35
+ const context = user[0];
36
+ const props = user[1];
37
+ const {
38
+ listRef,
39
+ elementsRef,
40
+ activeIndex,
41
+ onMatch: onMatchProp,
42
+ disabledIndices,
43
+ onTyping,
44
+ enabled = true,
45
+ resetMs = 750,
46
+ selectedIndex = null
47
+ } = props;
48
+ const store = context && "rootStore" in context ? context.rootStore : context;
49
+ const open = store.useState("open", (0, import_internal.subSlot)(slot, "open"));
50
+ const timeout = (0, import_useTimeout.useTimeout)((0, import_internal.subSlot)(slot, "to"));
51
+ const stringRef = (0, import_octane.useRef)("", (0, import_internal.subSlot)(slot, "str"));
52
+ const prevIndexRef = (0, import_octane.useRef)(
53
+ selectedIndex ?? activeIndex ?? -1,
54
+ (0, import_internal.subSlot)(slot, "prev")
55
+ );
56
+ const matchIndexRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "match"));
57
+ const onKeyDown = (0, import_useStableCallback.useStableCallback)(
58
+ (event) => {
59
+ function isVisible(index2) {
60
+ const element = elementsRef?.current[index2];
61
+ return !element || (0, import_composite.isElementVisible)(element);
62
+ }
63
+ function isItemAvailable(index2) {
64
+ if (!isVisible(index2)) {
65
+ return false;
66
+ }
67
+ return disabledIndices == null || !(0, import_list_utils.isListIndexDisabled)(import_empty.EMPTY_ARRAY, index2, disabledIndices);
68
+ }
69
+ function getMatchingIndex(list, string, startIndex2 = 0) {
70
+ if (list.length === 0) {
71
+ return -1;
72
+ }
73
+ const normalizedStartIndex = (startIndex2 % list.length + list.length) % list.length;
74
+ const lowerString = string.toLowerCase();
75
+ for (let offset = 0; offset < list.length; offset += 1) {
76
+ const index2 = (normalizedStartIndex + offset) % list.length;
77
+ const text = list[index2];
78
+ if (!text?.toLowerCase().startsWith(lowerString) || !isItemAvailable(index2)) {
79
+ continue;
80
+ }
81
+ return index2;
82
+ }
83
+ return -1;
84
+ }
85
+ const listContent = listRef.current;
86
+ if (stringRef.current.length > 0 && event.key === " ") {
87
+ (0, import_list_utils.stopEvent)(event);
88
+ onTyping?.(true);
89
+ }
90
+ if (stringRef.current.length > 0 && stringRef.current[0] !== " ") {
91
+ if (getMatchingIndex(listContent, stringRef.current) === -1 && event.key !== " ") {
92
+ onTyping?.(false);
93
+ }
94
+ }
95
+ if (listContent == null || // Character key.
96
+ event.key.length !== 1 || // Modifier key.
97
+ event.ctrlKey || event.metaKey || event.altKey) {
98
+ return;
99
+ }
100
+ if (open && event.key !== " ") {
101
+ (0, import_list_utils.stopEvent)(event);
102
+ onTyping?.(true);
103
+ }
104
+ const isNewSession = stringRef.current === "";
105
+ if (isNewSession) {
106
+ prevIndexRef.current = selectedIndex ?? activeIndex ?? -1;
107
+ }
108
+ const allowRapidSuccessionOfFirstLetter = listContent.every(
109
+ (text, index2) => text && isItemAvailable(index2) ? text[0]?.toLowerCase() !== text[1]?.toLowerCase() : true
110
+ );
111
+ if (allowRapidSuccessionOfFirstLetter && stringRef.current === event.key) {
112
+ stringRef.current = "";
113
+ prevIndexRef.current = matchIndexRef.current;
114
+ }
115
+ stringRef.current += event.key;
116
+ timeout.start(resetMs, () => {
117
+ stringRef.current = "";
118
+ prevIndexRef.current = matchIndexRef.current;
119
+ onTyping?.(false);
120
+ });
121
+ const prevIndex = isNewSession ? selectedIndex ?? activeIndex ?? -1 : prevIndexRef.current;
122
+ const startIndex = (prevIndex ?? 0) + 1;
123
+ const index = getMatchingIndex(listContent, stringRef.current, startIndex);
124
+ if (index !== -1) {
125
+ onMatchProp?.(index);
126
+ matchIndexRef.current = index;
127
+ } else if (event.key !== " ") {
128
+ stringRef.current = "";
129
+ onTyping?.(false);
130
+ }
131
+ },
132
+ (0, import_internal.subSlot)(slot, "okd")
133
+ );
134
+ const onBlur = (0, import_useStableCallback.useStableCallback)(
135
+ (event) => {
136
+ const next = event.relatedTarget;
137
+ const currentDomReferenceElement = store.select("domReferenceElement");
138
+ const currentFloatingElement = store.select("floatingElement");
139
+ const withinComposite = (0, import_element.contains)(currentDomReferenceElement, next) || (0, import_element.contains)(currentFloatingElement, next);
140
+ if (withinComposite) {
141
+ return;
142
+ }
143
+ timeout.clear();
144
+ stringRef.current = "";
145
+ prevIndexRef.current = matchIndexRef.current;
146
+ onTyping?.(false);
147
+ },
148
+ (0, import_internal.subSlot)(slot, "ob")
149
+ );
150
+ (0, import_octane.useLayoutEffect)(
151
+ () => {
152
+ if (!open && selectedIndex !== null) {
153
+ return;
154
+ }
155
+ timeout.clear();
156
+ matchIndexRef.current = null;
157
+ if (stringRef.current !== "") {
158
+ stringRef.current = "";
159
+ }
160
+ },
161
+ [open, selectedIndex, timeout],
162
+ (0, import_internal.subSlot)(slot, "e:reset")
163
+ );
164
+ (0, import_octane.useLayoutEffect)(
165
+ () => {
166
+ if (open && stringRef.current === "") {
167
+ prevIndexRef.current = selectedIndex ?? activeIndex ?? -1;
168
+ }
169
+ },
170
+ [open, selectedIndex, activeIndex],
171
+ (0, import_internal.subSlot)(slot, "e:sync")
172
+ );
173
+ const sharedProps = (0, import_octane.useMemo)(
174
+ () => ({ onKeyDown, onBlur }),
175
+ [onKeyDown, onBlur],
176
+ (0, import_internal.subSlot)(slot, "shared")
177
+ );
178
+ return (0, import_octane.useMemo)(
179
+ () => enabled ? { reference: sharedProps, floating: sharedProps } : {},
180
+ [enabled, sharedProps],
181
+ (0, import_internal.subSlot)(slot, "out")
182
+ );
183
+ }
184
+ // Annotate the CommonJS export names for ESM import in node:
185
+ 0 && (module.exports = {
186
+ useTypeahead
187
+ });
@@ -0,0 +1,60 @@
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 formatNumber_exports = {};
20
+ __export(formatNumber_exports, {
21
+ cache: () => cache,
22
+ formatNumber: () => formatNumber,
23
+ formatNumberValue: () => formatNumberValue,
24
+ getFormatter: () => getFormatter
25
+ });
26
+ module.exports = __toCommonJS(formatNumber_exports);
27
+ var import_stringifyLocale = require("./stringifyLocale.cjs");
28
+ const cache = /* @__PURE__ */ new Map();
29
+ function getFormatter(locale, options) {
30
+ const optionsString = JSON.stringify({ locale: (0, import_stringifyLocale.stringifyLocale)(locale), options });
31
+ const cachedFormatter = cache.get(optionsString);
32
+ if (cachedFormatter) {
33
+ return cachedFormatter;
34
+ }
35
+ const formatter = new Intl.NumberFormat(locale, options);
36
+ cache.set(optionsString, formatter);
37
+ return formatter;
38
+ }
39
+ function formatNumber(value, locale, options) {
40
+ if (value == null) {
41
+ return "";
42
+ }
43
+ return getFormatter(locale, options).format(value);
44
+ }
45
+ function formatNumberValue(value, locale, format) {
46
+ if (value == null) {
47
+ return "";
48
+ }
49
+ if (!format) {
50
+ return formatNumber(value / 100, locale, { style: "percent" });
51
+ }
52
+ return formatNumber(value, locale, format);
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ cache,
57
+ formatNumber,
58
+ formatNumberValue,
59
+ getFormatter
60
+ });
@@ -0,0 +1,32 @@
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 generateId_exports = {};
20
+ __export(generateId_exports, {
21
+ generateId: () => generateId
22
+ });
23
+ module.exports = __toCommonJS(generateId_exports);
24
+ let counter = 0;
25
+ function generateId(prefix) {
26
+ counter += 1;
27
+ return `${prefix}-${Math.random().toString(36).slice(2, 6)}-${counter}`;
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ generateId
32
+ });
@@ -0,0 +1,42 @@
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 getCssDimensions_exports = {};
20
+ __export(getCssDimensions_exports, {
21
+ getCssDimensions: () => getCssDimensions
22
+ });
23
+ module.exports = __toCommonJS(getCssDimensions_exports);
24
+ var import_dom = require("./dom.cjs");
25
+ function getCssDimensions(element) {
26
+ const css = getComputedStyle(element);
27
+ let width = parseFloat(css.width) || 0;
28
+ let height = parseFloat(css.height) || 0;
29
+ const hasOffset = (0, import_dom.isHTMLElement)(element);
30
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
31
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
32
+ const shouldFallback = Math.round(width * 2) / 2 !== offsetWidth || Math.round(height * 2) / 2 !== offsetHeight;
33
+ if (shouldFallback) {
34
+ width = offsetWidth;
35
+ height = offsetHeight;
36
+ }
37
+ return { width, height };
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ getCssDimensions
42
+ });
@@ -0,0 +1,42 @@
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 getDefaultFormSubmitter_exports = {};
20
+ __export(getDefaultFormSubmitter_exports, {
21
+ getDefaultFormSubmitter: () => getDefaultFormSubmitter
22
+ });
23
+ module.exports = __toCommonJS(getDefaultFormSubmitter_exports);
24
+ function getDefaultFormSubmitter(form) {
25
+ if (!form) {
26
+ return null;
27
+ }
28
+ for (const candidate of Array.from(form.elements)) {
29
+ const tagName = candidate.tagName;
30
+ if (tagName === "BUTTON" || tagName === "INPUT") {
31
+ const button = candidate;
32
+ if (button.type === "submit") {
33
+ return button;
34
+ }
35
+ }
36
+ }
37
+ return null;
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ getDefaultFormSubmitter
42
+ });
@@ -0,0 +1,32 @@
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 getDisabledMountTransitionStyles_exports = {};
20
+ __export(getDisabledMountTransitionStyles_exports, {
21
+ getDisabledMountTransitionStyles: () => getDisabledMountTransitionStyles
22
+ });
23
+ module.exports = __toCommonJS(getDisabledMountTransitionStyles_exports);
24
+ var import_empty = require("./empty.cjs");
25
+ var import_constants = require("./constants.cjs");
26
+ function getDisabledMountTransitionStyles(transitionStatus) {
27
+ return transitionStatus === "starting" ? import_constants.DISABLED_TRANSITIONS_STYLE : import_empty.EMPTY_OBJECT;
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ getDisabledMountTransitionStyles
32
+ });
@@ -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 getElementRef_exports = {};
20
+ __export(getElementRef_exports, {
21
+ getElementRef: () => getElementRef
22
+ });
23
+ module.exports = __toCommonJS(getElementRef_exports);
24
+ var import_octane = require("octane");
25
+ function getElementRef(element) {
26
+ if (!(0, import_octane.isValidElement)(element)) {
27
+ return null;
28
+ }
29
+ const props = element.props;
30
+ return props?.ref ?? null;
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ getElementRef
35
+ });
@@ -0,0 +1,56 @@
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 getPseudoElementBounds_exports = {};
20
+ __export(getPseudoElementBounds_exports, {
21
+ getPseudoElementBounds: () => getPseudoElementBounds
22
+ });
23
+ module.exports = __toCommonJS(getPseudoElementBounds_exports);
24
+ var import_owner = require("./owner.cjs");
25
+ var import_platform = require("./platform.cjs");
26
+ function getPseudoElementBounds(element) {
27
+ const elementRect = element.getBoundingClientRect();
28
+ const win = (0, import_owner.ownerWindow)(element);
29
+ if (import_platform.platform.env.jsdom) {
30
+ return elementRect;
31
+ }
32
+ const beforeStyles = win.getComputedStyle(element, "::before");
33
+ const afterStyles = win.getComputedStyle(element, "::after");
34
+ const hasPseudoElements = beforeStyles.content !== "none" || afterStyles.content !== "none";
35
+ if (!hasPseudoElements) {
36
+ return elementRect;
37
+ }
38
+ const beforeWidth = parseFloat(beforeStyles.width) || 0;
39
+ const beforeHeight = parseFloat(beforeStyles.height) || 0;
40
+ const afterWidth = parseFloat(afterStyles.width) || 0;
41
+ const afterHeight = parseFloat(afterStyles.height) || 0;
42
+ const totalWidth = Math.max(elementRect.width, beforeWidth, afterWidth);
43
+ const totalHeight = Math.max(elementRect.height, beforeHeight, afterHeight);
44
+ const widthDiff = totalWidth - elementRect.width;
45
+ const heightDiff = totalHeight - elementRect.height;
46
+ return {
47
+ left: elementRect.left - widthDiff / 2,
48
+ right: elementRect.right + widthDiff / 2,
49
+ top: elementRect.top - heightDiff / 2,
50
+ bottom: elementRect.bottom + heightDiff / 2
51
+ };
52
+ }
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ getPseudoElementBounds
56
+ });
@@ -0,0 +1,46 @@
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 getStateAttributesProps_exports = {};
20
+ __export(getStateAttributesProps_exports, {
21
+ getStateAttributesProps: () => getStateAttributesProps
22
+ });
23
+ module.exports = __toCommonJS(getStateAttributesProps_exports);
24
+ function getStateAttributesProps(state, customMapping) {
25
+ const props = {};
26
+ for (const key in state) {
27
+ const value = state[key];
28
+ if (customMapping?.hasOwnProperty(key)) {
29
+ const customProps = customMapping[key](value);
30
+ if (customProps != null) {
31
+ Object.assign(props, customProps);
32
+ }
33
+ continue;
34
+ }
35
+ if (value === true) {
36
+ props[`data-${key.toLowerCase()}`] = "";
37
+ } else if (value) {
38
+ props[`data-${key.toLowerCase()}`] = value.toString();
39
+ }
40
+ }
41
+ return props;
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ getStateAttributesProps
46
+ });
@@ -0,0 +1,42 @@
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 hideMiddleware_exports = {};
20
+ __export(hideMiddleware_exports, {
21
+ hide: () => hide
22
+ });
23
+ module.exports = __toCommonJS(hideMiddleware_exports);
24
+ var import_floating_ui = require("@octanejs/floating-ui");
25
+ const nativeHideFn = (0, import_floating_ui.hide)().fn;
26
+ const hide = {
27
+ name: "hide",
28
+ async fn(state) {
29
+ const { width, height, x, y } = state.rects.reference;
30
+ const anchorHidden = width === 0 && height === 0 && x === 0 && y === 0;
31
+ const nativeHideResult = await nativeHideFn(state);
32
+ return {
33
+ data: {
34
+ referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
35
+ }
36
+ };
37
+ }
38
+ };
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ hide
42
+ });