@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,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 useBaseUiId_exports = {};
20
+ __export(useBaseUiId_exports, {
21
+ useBaseUiId: () => useBaseUiId
22
+ });
23
+ module.exports = __toCommonJS(useBaseUiId_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ function useBaseUiId(...args) {
27
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
28
+ const slot = slotArg ?? (0, import_internal.S)("useBaseUiId");
29
+ const idOverride = user[0];
30
+ const id = (0, import_octane.useId)(slot);
31
+ return idOverride ?? `base-ui-${id}`;
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ useBaseUiId
36
+ });
@@ -0,0 +1,177 @@
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 useButton_exports = {};
20
+ __export(useButton_exports, {
21
+ useButton: () => useButton
22
+ });
23
+ module.exports = __toCommonJS(useButton_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ var import_mergeProps = require("./mergeProps.cjs");
27
+ var import_CompositeRootContext = require("./CompositeRootContext.cjs");
28
+ var import_useFocusableWhenDisabled = require("./useFocusableWhenDisabled.cjs");
29
+ var import_useStableCallback = require("./useStableCallback.cjs");
30
+ function isButtonElement(elem) {
31
+ return elem != null && elem instanceof HTMLElement && elem.tagName === "BUTTON";
32
+ }
33
+ function isValidLinkElement(elem) {
34
+ return Boolean(elem != null && elem.tagName === "A" && elem.href);
35
+ }
36
+ function useButton(...args) {
37
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
38
+ const slot = slotArg ?? (0, import_internal.S)("useButton");
39
+ const {
40
+ disabled = false,
41
+ focusableWhenDisabled,
42
+ tabIndex = 0,
43
+ native: isNativeButton = true,
44
+ composite: compositeProp
45
+ } = user[0] ?? {};
46
+ const elementRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "el"));
47
+ const compositeRootContext = (0, import_CompositeRootContext.useCompositeRootContext)(true);
48
+ const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
49
+ const { props: focusableWhenDisabledProps } = (0, import_useFocusableWhenDisabled.useFocusableWhenDisabled)(
50
+ { focusableWhenDisabled, disabled, composite: isCompositeItem, tabIndex, isNativeButton },
51
+ (0, import_internal.subSlot)(slot, "fwd")
52
+ );
53
+ const updateDisabled = (0, import_octane.useCallback)(
54
+ () => {
55
+ const element = elementRef.current;
56
+ if (!isButtonElement(element)) {
57
+ return;
58
+ }
59
+ if (isCompositeItem && disabled && focusableWhenDisabledProps.disabled === void 0 && element.disabled) {
60
+ element.disabled = false;
61
+ }
62
+ },
63
+ [disabled, focusableWhenDisabledProps.disabled, isCompositeItem],
64
+ (0, import_internal.subSlot)(slot, "upd")
65
+ );
66
+ (0, import_octane.useLayoutEffect)(updateDisabled, [updateDisabled], (0, import_internal.subSlot)(slot, "e:upd"));
67
+ const getButtonProps = (0, import_octane.useCallback)(
68
+ (externalProps = {}) => {
69
+ const {
70
+ onClick: externalOnClick,
71
+ onMouseDown: externalOnMouseDown,
72
+ onKeyUp: externalOnKeyUp,
73
+ onKeyDown: externalOnKeyDown,
74
+ onPointerDown: externalOnPointerDown,
75
+ ...otherExternalProps
76
+ } = externalProps;
77
+ return (0, import_mergeProps.mergeProps)(
78
+ {
79
+ onClick(event) {
80
+ if (disabled) {
81
+ event.preventDefault();
82
+ return;
83
+ }
84
+ externalOnClick?.(event);
85
+ },
86
+ onMouseDown(event) {
87
+ if (!disabled) {
88
+ externalOnMouseDown?.(event);
89
+ }
90
+ },
91
+ onKeyDown(event) {
92
+ if (disabled) {
93
+ return;
94
+ }
95
+ (0, import_mergeProps.makeEventPreventable)(event);
96
+ externalOnKeyDown?.(event);
97
+ if (event.baseUIHandlerPrevented) {
98
+ return;
99
+ }
100
+ const isCurrentTarget = event.target === event.currentTarget;
101
+ const currentTarget = event.currentTarget;
102
+ const isButton = isButtonElement(currentTarget);
103
+ const isLink = !isNativeButton && isValidLinkElement(currentTarget);
104
+ const shouldClick = isCurrentTarget && (isNativeButton ? isButton : !isLink);
105
+ const isEnterKey = event.key === "Enter";
106
+ const isSpaceKey = event.key === " ";
107
+ const role = currentTarget.getAttribute("role");
108
+ const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
109
+ if (isCurrentTarget && isCompositeItem && isSpaceKey) {
110
+ if (event.defaultPrevented && isTextNavigationRole) {
111
+ return;
112
+ }
113
+ event.preventDefault();
114
+ if (isLink || isNativeButton && isButton) {
115
+ currentTarget.click();
116
+ event.preventBaseUIHandler();
117
+ } else if (shouldClick) {
118
+ externalOnClick?.(event);
119
+ event.preventBaseUIHandler();
120
+ }
121
+ return;
122
+ }
123
+ if (shouldClick) {
124
+ if (!isNativeButton && (isSpaceKey || isEnterKey)) {
125
+ event.preventDefault();
126
+ }
127
+ if (!isNativeButton && isEnterKey) {
128
+ externalOnClick?.(event);
129
+ }
130
+ }
131
+ },
132
+ onKeyUp(event) {
133
+ if (disabled) {
134
+ return;
135
+ }
136
+ (0, import_mergeProps.makeEventPreventable)(event);
137
+ externalOnKeyUp?.(event);
138
+ if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
139
+ event.preventDefault();
140
+ return;
141
+ }
142
+ if (event.baseUIHandlerPrevented) {
143
+ return;
144
+ }
145
+ if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") {
146
+ externalOnClick?.(event);
147
+ }
148
+ },
149
+ onPointerDown(event) {
150
+ if (disabled) {
151
+ event.preventDefault();
152
+ return;
153
+ }
154
+ externalOnPointerDown?.(event);
155
+ }
156
+ },
157
+ isNativeButton ? { type: "button" } : { role: "button" },
158
+ focusableWhenDisabledProps,
159
+ otherExternalProps
160
+ );
161
+ },
162
+ [disabled, focusableWhenDisabledProps, isCompositeItem, isNativeButton],
163
+ (0, import_internal.subSlot)(slot, "gbp")
164
+ );
165
+ const buttonRef = (0, import_useStableCallback.useStableCallback)(
166
+ (element) => {
167
+ elementRef.current = element;
168
+ updateDisabled();
169
+ },
170
+ (0, import_internal.subSlot)(slot, "ref")
171
+ );
172
+ return { getButtonProps, buttonRef };
173
+ }
174
+ // Annotate the CommonJS export names for ESM import in node:
175
+ 0 && (module.exports = {
176
+ useButton
177
+ });
@@ -0,0 +1,114 @@
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 useCheckboxGroupParent_exports = {};
20
+ __export(useCheckboxGroupParent_exports, {
21
+ useCheckboxGroupParent: () => useCheckboxGroupParent
22
+ });
23
+ module.exports = __toCommonJS(useCheckboxGroupParent_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ var import_useBaseUiId = require("./useBaseUiId.cjs");
27
+ var import_useStableCallback = require("./useStableCallback.cjs");
28
+ const EMPTY = [];
29
+ function useCheckboxGroupParent(...args) {
30
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
31
+ const slot = slotArg ?? (0, import_internal.S)("useCheckboxGroupParent");
32
+ const {
33
+ allValues = EMPTY,
34
+ value = EMPTY,
35
+ onValueChange: onValueChangeProp
36
+ } = user[0] ?? {};
37
+ const uncontrolledStateRef = (0, import_octane.useRef)(value, (0, import_internal.subSlot)(slot, "uncontrolled"));
38
+ const disabledStatesRef = (0, import_octane.useRef)(/* @__PURE__ */ new Map(), (0, import_internal.subSlot)(slot, "disabledStates"));
39
+ const [status, setStatus] = (0, import_octane.useState)("mixed", (0, import_internal.subSlot)(slot, "status"));
40
+ const id = (0, import_useBaseUiId.useBaseUiId)(void 0, (0, import_internal.subSlot)(slot, "id"));
41
+ const checked = value.length === allValues.length;
42
+ const indeterminate = value.length !== allValues.length && value.length > 0;
43
+ const onValueChange = (0, import_useStableCallback.useStableCallback)(onValueChangeProp, (0, import_internal.subSlot)(slot, "onValueChange"));
44
+ const getParentProps = (0, import_octane.useCallback)(
45
+ () => ({
46
+ id,
47
+ indeterminate,
48
+ checked,
49
+ "aria-controls": allValues.map((v) => `${id}-${v}`).join(" "),
50
+ onCheckedChange(_, eventDetails) {
51
+ const uncontrolledState = uncontrolledStateRef.current;
52
+ const none = allValues.filter(
53
+ (v) => disabledStatesRef.current.get(v) && uncontrolledState.includes(v)
54
+ );
55
+ const all = allValues.filter(
56
+ (v) => !disabledStatesRef.current.get(v) || disabledStatesRef.current.get(v) && uncontrolledState.includes(v)
57
+ );
58
+ const allOnOrOff = uncontrolledState.length === all.length || uncontrolledState.length === 0;
59
+ if (allOnOrOff) {
60
+ if (value.length === all.length) {
61
+ onValueChange(none, eventDetails);
62
+ } else {
63
+ onValueChange(all, eventDetails);
64
+ }
65
+ return;
66
+ }
67
+ let nextStatus = "mixed";
68
+ let nextValue = uncontrolledState;
69
+ if (status === "mixed") {
70
+ nextStatus = "on";
71
+ nextValue = all;
72
+ } else if (status === "on") {
73
+ nextStatus = "off";
74
+ nextValue = none;
75
+ }
76
+ onValueChange(nextValue, eventDetails);
77
+ if (!eventDetails.isCanceled) {
78
+ setStatus(nextStatus);
79
+ }
80
+ }
81
+ }),
82
+ [allValues, checked, id, indeterminate, onValueChange, status, value.length],
83
+ (0, import_internal.subSlot)(slot, "getParentProps")
84
+ );
85
+ const getChildProps = (0, import_octane.useCallback)(
86
+ (childValue) => ({
87
+ checked: value.includes(childValue),
88
+ onCheckedChange(nextChecked, eventDetails) {
89
+ const newValue = value.slice();
90
+ if (nextChecked) {
91
+ newValue.push(childValue);
92
+ } else {
93
+ newValue.splice(newValue.indexOf(childValue), 1);
94
+ }
95
+ onValueChange(newValue, eventDetails);
96
+ if (!eventDetails.isCanceled) {
97
+ uncontrolledStateRef.current = newValue;
98
+ setStatus("mixed");
99
+ }
100
+ }
101
+ }),
102
+ [onValueChange, value],
103
+ (0, import_internal.subSlot)(slot, "getChildProps")
104
+ );
105
+ return (0, import_octane.useMemo)(
106
+ () => ({ id, indeterminate, getParentProps, getChildProps, disabledStatesRef }),
107
+ [id, indeterminate, getParentProps, getChildProps],
108
+ (0, import_internal.subSlot)(slot, "return")
109
+ );
110
+ }
111
+ // Annotate the CommonJS export names for ESM import in node:
112
+ 0 && (module.exports = {
113
+ useCheckboxGroupParent
114
+ });
@@ -0,0 +1,47 @@
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 useControlled_exports = {};
20
+ __export(useControlled_exports, {
21
+ useControlled: () => useControlled
22
+ });
23
+ module.exports = __toCommonJS(useControlled_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ function useControlled(...args) {
27
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
28
+ const slot = slotArg ?? (0, import_internal.S)("useControlled");
29
+ const { controlled, default: defaultProp } = user[0];
30
+ const { current: isControlled } = (0, import_octane.useRef)(controlled !== void 0, (0, import_internal.subSlot)(slot, "ctrl"));
31
+ const [valueState, setValue] = (0, import_octane.useState)(defaultProp, (0, import_internal.subSlot)(slot, "val"));
32
+ const value = isControlled ? controlled : valueState;
33
+ const setValueIfUncontrolled = (0, import_octane.useCallback)(
34
+ (newValue) => {
35
+ if (!isControlled) {
36
+ setValue(newValue);
37
+ }
38
+ },
39
+ [],
40
+ (0, import_internal.subSlot)(slot, "set")
41
+ );
42
+ return [value, setValueIfUncontrolled];
43
+ }
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ useControlled
47
+ });
@@ -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 useEnhancedClickHandler_exports = {};
20
+ __export(useEnhancedClickHandler_exports, {
21
+ useEnhancedClickHandler: () => useEnhancedClickHandler
22
+ });
23
+ module.exports = __toCommonJS(useEnhancedClickHandler_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ function useEnhancedClickHandler(handler, slot) {
27
+ const lastClickInteractionTypeRef = (0, import_octane.useRef)("", (0, import_internal.subSlot)(slot, "last"));
28
+ const handlePointerDown = (0, import_octane.useCallback)(
29
+ (event) => {
30
+ if (event.defaultPrevented) {
31
+ return;
32
+ }
33
+ lastClickInteractionTypeRef.current = event.pointerType;
34
+ handler(event, event.pointerType);
35
+ },
36
+ [handler],
37
+ (0, import_internal.subSlot)(slot, "pd")
38
+ );
39
+ const handleClick = (0, import_octane.useCallback)(
40
+ (event) => {
41
+ if (event.detail === 0) {
42
+ handler(event, "keyboard");
43
+ return;
44
+ }
45
+ if ("pointerType" in event) {
46
+ handler(event, event.pointerType);
47
+ } else {
48
+ handler(event, lastClickInteractionTypeRef.current);
49
+ }
50
+ lastClickInteractionTypeRef.current = "";
51
+ },
52
+ [handler],
53
+ (0, import_internal.subSlot)(slot, "click")
54
+ );
55
+ return { onClick: handleClick, onPointerDown: handlePointerDown };
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ useEnhancedClickHandler
60
+ });
@@ -0,0 +1,77 @@
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 useFocusableWhenDisabled_exports = {};
20
+ __export(useFocusableWhenDisabled_exports, {
21
+ useFocusableWhenDisabled: () => useFocusableWhenDisabled
22
+ });
23
+ module.exports = __toCommonJS(useFocusableWhenDisabled_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ function useFocusableWhenDisabled(...args) {
27
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
28
+ const slot = slotArg ?? (0, import_internal.S)("useFocusableWhenDisabled");
29
+ const {
30
+ focusableWhenDisabled,
31
+ disabled,
32
+ composite = false,
33
+ tabIndex: tabIndexProp = 0,
34
+ isNativeButton
35
+ } = user[0];
36
+ const isFocusableComposite = composite && focusableWhenDisabled !== false;
37
+ const isNonFocusableComposite = composite && focusableWhenDisabled === false;
38
+ const props = (0, import_octane.useMemo)(
39
+ () => {
40
+ const additionalProps = {
41
+ onKeyDown(event) {
42
+ if (disabled && focusableWhenDisabled && event.key !== "Tab") {
43
+ event.preventDefault();
44
+ }
45
+ }
46
+ };
47
+ if (!composite) {
48
+ additionalProps.tabIndex = tabIndexProp;
49
+ if (!isNativeButton && disabled) {
50
+ additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
51
+ }
52
+ }
53
+ if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled) {
54
+ additionalProps["aria-disabled"] = disabled;
55
+ }
56
+ if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {
57
+ additionalProps.disabled = disabled;
58
+ }
59
+ return additionalProps;
60
+ },
61
+ [
62
+ composite,
63
+ disabled,
64
+ focusableWhenDisabled,
65
+ isFocusableComposite,
66
+ isNonFocusableComposite,
67
+ isNativeButton,
68
+ tabIndexProp
69
+ ],
70
+ slot
71
+ );
72
+ return { props };
73
+ }
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ useFocusableWhenDisabled
77
+ });
@@ -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 useForcedRerendering_exports = {};
20
+ __export(useForcedRerendering_exports, {
21
+ useForcedRerendering: () => useForcedRerendering
22
+ });
23
+ module.exports = __toCommonJS(useForcedRerendering_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ function useForcedRerendering(...args) {
27
+ const [, slotArg] = (0, import_internal.splitSlot)(["_", ...args]);
28
+ const slot = slotArg ?? (0, import_internal.S)("useForcedRerendering");
29
+ const [, setState] = (0, import_octane.useState)({}, (0, import_internal.subSlot)(slot, "state"));
30
+ return (0, import_octane.useCallback)(() => setState({}), [], (0, import_internal.subSlot)(slot, "cb"));
31
+ }
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ useForcedRerendering
35
+ });
@@ -0,0 +1,44 @@
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 useIsHydrating_exports = {};
20
+ __export(useIsHydrating_exports, {
21
+ useIsHydrating: () => useIsHydrating
22
+ });
23
+ module.exports = __toCommonJS(useIsHydrating_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ function subscribe() {
27
+ return () => {
28
+ };
29
+ }
30
+ function getSnapshot() {
31
+ return false;
32
+ }
33
+ function getServerSnapshot() {
34
+ return true;
35
+ }
36
+ function useIsHydrating(...args) {
37
+ const [, slotArg] = (0, import_internal.splitSlot)(args);
38
+ const slot = slotArg ?? (0, import_internal.S)("useIsHydrating");
39
+ return (0, import_octane.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot, (0, import_internal.subSlot)(slot, "store"));
40
+ }
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ useIsHydrating
44
+ });
@@ -0,0 +1,66 @@
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 useMixedToggleClickHandler_exports = {};
20
+ __export(useMixedToggleClickHandler_exports, {
21
+ useMixedToggleClickHandler: () => useMixedToggleClickHandler
22
+ });
23
+ module.exports = __toCommonJS(useMixedToggleClickHandler_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("../internal.cjs");
26
+ var import_empty = require("./empty.cjs");
27
+ var import_owner = require("./owner.cjs");
28
+ function useMixedToggleClickHandler(...args) {
29
+ const [user, slotArg] = (0, import_internal.splitSlot)(args);
30
+ const slot = slotArg ?? (0, import_internal.S)("useMixedToggleClickHandler");
31
+ const { enabled = true, mouseDownAction, open } = user[0];
32
+ const ignoreClickRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "ignore"));
33
+ return (0, import_octane.useMemo)(
34
+ () => {
35
+ if (!enabled) {
36
+ return import_empty.EMPTY_OBJECT;
37
+ }
38
+ return {
39
+ onMouseDown: (event) => {
40
+ if (mouseDownAction === "open" && !open || mouseDownAction === "close" && open) {
41
+ ignoreClickRef.current = true;
42
+ (0, import_owner.ownerDocument)(event.currentTarget).addEventListener(
43
+ "click",
44
+ () => {
45
+ ignoreClickRef.current = false;
46
+ },
47
+ { once: true }
48
+ );
49
+ }
50
+ },
51
+ onClick: (event) => {
52
+ if (ignoreClickRef.current) {
53
+ ignoreClickRef.current = false;
54
+ event.preventBaseUIHandler();
55
+ }
56
+ }
57
+ };
58
+ },
59
+ [enabled, mouseDownAction, open],
60
+ (0, import_internal.subSlot)(slot, "m")
61
+ );
62
+ }
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ useMixedToggleClickHandler
66
+ });