@octanejs/base-ui 0.1.31 → 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.
- package/dist/cjs/accordion.cjs +497 -0
- package/dist/cjs/alert-dialog.cjs +65 -0
- package/dist/cjs/avatar.cjs +234 -0
- package/dist/cjs/button.cjs +54 -0
- package/dist/cjs/checkbox-group.cjs +165 -0
- package/dist/cjs/checkbox.cjs +475 -0
- package/dist/cjs/collapsible.cjs +700 -0
- package/dist/cjs/context-menu.cjs +257 -0
- package/dist/cjs/csp-provider.cjs +40 -0
- package/dist/cjs/dialog.cjs +741 -0
- package/dist/cjs/direction-provider.cjs +35 -0
- package/dist/cjs/field.cjs +559 -0
- package/dist/cjs/fieldset.cjs +101 -0
- package/dist/cjs/form.cjs +177 -0
- package/dist/cjs/index.cjs +133 -0
- package/dist/cjs/input.cjs +32 -0
- package/dist/cjs/internal.cjs +51 -0
- package/dist/cjs/menu.cjs +2420 -0
- package/dist/cjs/menubar.cjs +132 -0
- package/dist/cjs/merge-props.cjs +34 -0
- package/dist/cjs/meter.cjs +169 -0
- package/dist/cjs/number-field.cjs +812 -0
- package/dist/cjs/popover.cjs +966 -0
- package/dist/cjs/preview-card.cjs +632 -0
- package/dist/cjs/progress.cjs +206 -0
- package/dist/cjs/radio-group.cjs +264 -0
- package/dist/cjs/radio.cjs +327 -0
- package/dist/cjs/separator.cjs +44 -0
- package/dist/cjs/slider.cjs +1384 -0
- package/dist/cjs/switch.cjs +306 -0
- package/dist/cjs/tabs.cjs +727 -0
- package/dist/cjs/toast.cjs +1766 -0
- package/dist/cjs/toggle-group.cjs +118 -0
- package/dist/cjs/toggle.cjs +121 -0
- package/dist/cjs/tooltip.cjs +835 -0
- package/dist/cjs/unstable-use-media-query.cjs +79 -0
- package/dist/cjs/use-render.cjs +40 -0
- package/dist/cjs/utils/CSPContext.cjs +38 -0
- package/dist/cjs/utils/CheckboxGroupContext.cjs +40 -0
- package/dist/cjs/utils/CompositeRootContext.cjs +40 -0
- package/dist/cjs/utils/ContextMenuRootContext.cjs +42 -0
- package/dist/cjs/utils/DirectionContext.cjs +34 -0
- package/dist/cjs/utils/FloatingPortalLite.cjs +47 -0
- package/dist/cjs/utils/InternalBackdrop.cjs +49 -0
- package/dist/cjs/utils/MenubarContext.cjs +40 -0
- package/dist/cjs/utils/RadioGroupContext.cjs +34 -0
- package/dist/cjs/utils/RequestQueue.cjs +111 -0
- package/dist/cjs/utils/TimeoutManager.cjs +50 -0
- package/dist/cjs/utils/ToggleGroupContext.cjs +40 -0
- package/dist/cjs/utils/adaptiveOriginMiddleware.cjs +94 -0
- package/dist/cjs/utils/addEventListener.cjs +33 -0
- package/dist/cjs/utils/areArraysEqual.cjs +30 -0
- package/dist/cjs/utils/clamp.cjs +30 -0
- package/dist/cjs/utils/closePart.cjs +70 -0
- package/dist/cjs/utils/collapsibleOpenStateMapping.cjs +42 -0
- package/dist/cjs/utils/composeRefs.cjs +68 -0
- package/dist/cjs/utils/composite/CompositeItem.cjs +59 -0
- package/dist/cjs/utils/composite/CompositeList.cjs +177 -0
- package/dist/cjs/utils/composite/CompositeListContext.cjs +43 -0
- package/dist/cjs/utils/composite/CompositeRoot.cjs +118 -0
- package/dist/cjs/utils/composite/grid-utils.cjs +343 -0
- package/dist/cjs/utils/composite/gridNavigation.cjs +92 -0
- package/dist/cjs/utils/composite/keys.cjs +174 -0
- package/dist/cjs/utils/composite/list-utils.cjs +90 -0
- package/dist/cjs/utils/composite/useCompositeItem.cjs +63 -0
- package/dist/cjs/utils/composite/useCompositeListItem.cjs +104 -0
- package/dist/cjs/utils/composite/useCompositeRoot.cjs +263 -0
- package/dist/cjs/utils/constants.cjs +56 -0
- package/dist/cjs/utils/contains.cjs +46 -0
- package/dist/cjs/utils/createChangeEventDetails.cjs +92 -0
- package/dist/cjs/utils/dom.cjs +35 -0
- package/dist/cjs/utils/empty.cjs +34 -0
- package/dist/cjs/utils/field/FieldItemContext.cjs +34 -0
- package/dist/cjs/utils/field/FieldRootContext.cjs +80 -0
- package/dist/cjs/utils/field/FormContext.cjs +41 -0
- package/dist/cjs/utils/field/LabelableContext.cjs +43 -0
- package/dist/cjs/utils/field/LabelableProvider.cjs +115 -0
- package/dist/cjs/utils/field/constants.cjs +68 -0
- package/dist/cjs/utils/field/getCombinedFieldValidityData.cjs +36 -0
- package/dist/cjs/utils/field/useAriaLabelledBy.cjs +87 -0
- package/dist/cjs/utils/field/useFieldControlRegistration.cjs +165 -0
- package/dist/cjs/utils/field/useFieldValidation.cjs +285 -0
- package/dist/cjs/utils/field/useLabel.cjs +99 -0
- package/dist/cjs/utils/field/useLabelableId.cjs +105 -0
- package/dist/cjs/utils/field/useRegisterFieldControl.cjs +60 -0
- package/dist/cjs/utils/findRootOwnerId.cjs +37 -0
- package/dist/cjs/utils/floating/FloatingDelayGroup.cjs +219 -0
- package/dist/cjs/utils/floating/FloatingFocusManager.cjs +685 -0
- package/dist/cjs/utils/floating/FloatingPortal.cjs +230 -0
- package/dist/cjs/utils/floating/FloatingRootStore.cjs +87 -0
- package/dist/cjs/utils/floating/FloatingTree.cjs +86 -0
- package/dist/cjs/utils/floating/FloatingTreeStore.cjs +41 -0
- package/dist/cjs/utils/floating/FocusGuard.cjs +54 -0
- package/dist/cjs/utils/floating/composite.cjs +42 -0
- package/dist/cjs/utils/floating/constants.cjs +34 -0
- package/dist/cjs/utils/floating/createAttribute.cjs +30 -0
- package/dist/cjs/utils/floating/createEventEmitter.cjs +44 -0
- package/dist/cjs/utils/floating/element.cjs +103 -0
- package/dist/cjs/utils/floating/enqueueFocus.cjs +51 -0
- package/dist/cjs/utils/floating/event.cjs +65 -0
- package/dist/cjs/utils/floating/getEmptyRootContext.cjs +42 -0
- package/dist/cjs/utils/floating/gridNavigation.cjs +45 -0
- package/dist/cjs/utils/floating/markOthers.cjs +181 -0
- package/dist/cjs/utils/floating/nodes.cjs +48 -0
- package/dist/cjs/utils/floating/safePolygon.cjs +301 -0
- package/dist/cjs/utils/floating/tabbable.cjs +242 -0
- package/dist/cjs/utils/floating/types.cjs +16 -0
- package/dist/cjs/utils/floating/useClick.cjs +153 -0
- package/dist/cjs/utils/floating/useClientPoint.cjs +225 -0
- package/dist/cjs/utils/floating/useDismiss.cjs +506 -0
- package/dist/cjs/utils/floating/useFloating.cjs +186 -0
- package/dist/cjs/utils/floating/useFloatingRootContext.cjs +75 -0
- package/dist/cjs/utils/floating/useFocus.cjs +184 -0
- package/dist/cjs/utils/floating/useHoverFloatingInteraction.cjs +231 -0
- package/dist/cjs/utils/floating/useHoverInteractionSharedState.cjs +113 -0
- package/dist/cjs/utils/floating/useHoverReferenceInteraction.cjs +380 -0
- package/dist/cjs/utils/floating/useHoverShared.cjs +65 -0
- package/dist/cjs/utils/floating/useListNavigation.cjs +665 -0
- package/dist/cjs/utils/floating/useSyncedFloatingRootContext.cjs +91 -0
- package/dist/cjs/utils/floating/useTypeahead.cjs +187 -0
- package/dist/cjs/utils/formatNumber.cjs +60 -0
- package/dist/cjs/utils/generateId.cjs +32 -0
- package/dist/cjs/utils/getCssDimensions.cjs +42 -0
- package/dist/cjs/utils/getDefaultFormSubmitter.cjs +42 -0
- package/dist/cjs/utils/getDisabledMountTransitionStyles.cjs +32 -0
- package/dist/cjs/utils/getElementRef.cjs +35 -0
- package/dist/cjs/utils/getPseudoElementBounds.cjs +56 -0
- package/dist/cjs/utils/getStateAttributesProps.cjs +46 -0
- package/dist/cjs/utils/hideMiddleware.cjs +42 -0
- package/dist/cjs/utils/inertValue.cjs +30 -0
- package/dist/cjs/utils/matchesFocusVisible.cjs +38 -0
- package/dist/cjs/utils/mergeCleanups.cjs +37 -0
- package/dist/cjs/utils/mergeObjects.cjs +39 -0
- package/dist/cjs/utils/mergeProps.cjs +182 -0
- package/dist/cjs/utils/noop.cjs +29 -0
- package/dist/cjs/utils/number/constants.cjs +34 -0
- package/dist/cjs/utils/number/parse.cjs +258 -0
- package/dist/cjs/utils/number/types.cjs +16 -0
- package/dist/cjs/utils/number/validate.cjs +104 -0
- package/dist/cjs/utils/owner.cjs +35 -0
- package/dist/cjs/utils/platform.cjs +83 -0
- package/dist/cjs/utils/popupStateMapping.cjs +74 -0
- package/dist/cjs/utils/popups/index.cjs +39 -0
- package/dist/cjs/utils/popups/inlineRect.cjs +218 -0
- package/dist/cjs/utils/popups/popupStoreUtils.cjs +379 -0
- package/dist/cjs/utils/popups/popupTriggerMap.cjs +76 -0
- package/dist/cjs/utils/popups/store.cjs +118 -0
- package/dist/cjs/utils/popups/useTriggerFocusGuards.cjs +72 -0
- package/dist/cjs/utils/resolveAriaLabelledBy.cjs +35 -0
- package/dist/cjs/utils/resolveClassName.cjs +30 -0
- package/dist/cjs/utils/resolveRef.cjs +33 -0
- package/dist/cjs/utils/resolveStyle.cjs +30 -0
- package/dist/cjs/utils/serializeValue.cjs +40 -0
- package/dist/cjs/utils/slider/asc.cjs +30 -0
- package/dist/cjs/utils/slider/getMidpoint.cjs +34 -0
- package/dist/cjs/utils/slider/getPushedThumbValues.cjs +73 -0
- package/dist/cjs/utils/slider/getSliderValue.cjs +42 -0
- package/dist/cjs/utils/slider/replaceArrayItemAtIndex.cjs +33 -0
- package/dist/cjs/utils/slider/resolveThumbCollision.cjs +155 -0
- package/dist/cjs/utils/slider/roundValueToStep.cjs +45 -0
- package/dist/cjs/utils/slider/validateMinimumDistance.cjs +40 -0
- package/dist/cjs/utils/slider/valueArrayToPercentages.cjs +36 -0
- package/dist/cjs/utils/store/ReactStore.cjs +135 -0
- package/dist/cjs/utils/store/Store.cjs +83 -0
- package/dist/cjs/utils/store/createSelector.cjs +74 -0
- package/dist/cjs/utils/store/useStore.cjs +51 -0
- package/dist/cjs/utils/stringifyLocale.cjs +36 -0
- package/dist/cjs/utils/useAnchorPositioning.cjs +421 -0
- package/dist/cjs/utils/useAnchoredPopupScrollLock.cjs +59 -0
- package/dist/cjs/utils/useAnimationFrame.cjs +93 -0
- package/dist/cjs/utils/useAnimationsFinished.cjs +98 -0
- package/dist/cjs/utils/useBaseUiId.cjs +36 -0
- package/dist/cjs/utils/useButton.cjs +177 -0
- package/dist/cjs/utils/useCheckboxGroupParent.cjs +114 -0
- package/dist/cjs/utils/useControlled.cjs +47 -0
- package/dist/cjs/utils/useEnhancedClickHandler.cjs +60 -0
- package/dist/cjs/utils/useFocusableWhenDisabled.cjs +77 -0
- package/dist/cjs/utils/useForcedRerendering.cjs +35 -0
- package/dist/cjs/utils/useIsHydrating.cjs +44 -0
- package/dist/cjs/utils/useMixedToggleClickHandler.cjs +66 -0
- package/dist/cjs/utils/useOnFirstRender.cjs +35 -0
- package/dist/cjs/utils/useOnMount.cjs +36 -0
- package/dist/cjs/utils/useOpenChangeComplete.cjs +57 -0
- package/dist/cjs/utils/useOpenInteractionType.cjs +69 -0
- package/dist/cjs/utils/usePopupAutoResize.cjs +191 -0
- package/dist/cjs/utils/usePopupViewport.cjs +283 -0
- package/dist/cjs/utils/usePositioner.cjs +53 -0
- package/dist/cjs/utils/usePressAndHold.cjs +51 -0
- package/dist/cjs/utils/usePreviousValue.cjs +47 -0
- package/dist/cjs/utils/useRefWithInit.cjs +41 -0
- package/dist/cjs/utils/useRegisteredLabelId.cjs +48 -0
- package/dist/cjs/utils/useRenderElement.cjs +106 -0
- package/dist/cjs/utils/useScrollLock.cjs +232 -0
- package/dist/cjs/utils/useStableCallback.cjs +41 -0
- package/dist/cjs/utils/useTimeout.cjs +66 -0
- package/dist/cjs/utils/useTransitionStatus.cjs +116 -0
- package/dist/cjs/utils/useValueAsRef.cjs +43 -0
- package/dist/cjs/utils/useValueChanged.cjs +55 -0
- package/dist/cjs/utils/valueToPercent.cjs +30 -0
- package/dist/cjs/utils/visuallyHidden.cjs +49 -0
- package/package.json +20 -8
|
@@ -0,0 +1,43 @@
|
|
|
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 CompositeListContext_exports = {};
|
|
20
|
+
__export(CompositeListContext_exports, {
|
|
21
|
+
CompositeListContext: () => CompositeListContext,
|
|
22
|
+
useCompositeListContext: () => useCompositeListContext
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(CompositeListContext_exports);
|
|
25
|
+
var import_octane = require("octane");
|
|
26
|
+
const CompositeListContext = (0, import_octane.createContext)({
|
|
27
|
+
register: () => {
|
|
28
|
+
},
|
|
29
|
+
unregister: () => {
|
|
30
|
+
},
|
|
31
|
+
subscribeMapChange: () => () => {
|
|
32
|
+
},
|
|
33
|
+
elementsRef: { current: [] },
|
|
34
|
+
nextIndexRef: { current: 0 }
|
|
35
|
+
});
|
|
36
|
+
function useCompositeListContext() {
|
|
37
|
+
return (0, import_octane.useContext)(CompositeListContext);
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
CompositeListContext,
|
|
42
|
+
useCompositeListContext
|
|
43
|
+
});
|
|
@@ -0,0 +1,118 @@
|
|
|
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 CompositeRoot_exports = {};
|
|
20
|
+
__export(CompositeRoot_exports, {
|
|
21
|
+
CompositeRoot: () => CompositeRoot
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(CompositeRoot_exports);
|
|
24
|
+
var import_octane = require("octane");
|
|
25
|
+
var import_internal = require("../../internal.cjs");
|
|
26
|
+
var import_useRenderElement = require("../useRenderElement.cjs");
|
|
27
|
+
var import_DirectionContext = require("../DirectionContext.cjs");
|
|
28
|
+
var import_CompositeRootContext = require("../CompositeRootContext.cjs");
|
|
29
|
+
var import_CompositeList = require("./CompositeList.cjs");
|
|
30
|
+
var import_useCompositeRoot = require("./useCompositeRoot.cjs");
|
|
31
|
+
const EMPTY_ARRAY = [];
|
|
32
|
+
const EMPTY_OBJECT = {};
|
|
33
|
+
function CompositeRoot(componentProps) {
|
|
34
|
+
const slot = (0, import_internal.S)("CompositeRoot");
|
|
35
|
+
const {
|
|
36
|
+
render,
|
|
37
|
+
className,
|
|
38
|
+
style,
|
|
39
|
+
refs = EMPTY_ARRAY,
|
|
40
|
+
props = EMPTY_ARRAY,
|
|
41
|
+
state = EMPTY_OBJECT,
|
|
42
|
+
stateAttributesMapping,
|
|
43
|
+
highlightedIndex: highlightedIndexProp,
|
|
44
|
+
onHighlightedIndexChange: onHighlightedIndexChangeProp,
|
|
45
|
+
orientation,
|
|
46
|
+
grid,
|
|
47
|
+
loopFocus,
|
|
48
|
+
onLoop,
|
|
49
|
+
enableHomeAndEndKeys,
|
|
50
|
+
onMapChange: onMapChangeProp,
|
|
51
|
+
stopEventPropagation = true,
|
|
52
|
+
rootRef,
|
|
53
|
+
disabledIndices,
|
|
54
|
+
modifierKeys,
|
|
55
|
+
highlightItemOnHover = false,
|
|
56
|
+
tag = "div",
|
|
57
|
+
...elementProps
|
|
58
|
+
} = componentProps;
|
|
59
|
+
const direction = (0, import_DirectionContext.useDirection)();
|
|
60
|
+
const {
|
|
61
|
+
props: defaultProps,
|
|
62
|
+
highlightedIndex,
|
|
63
|
+
onHighlightedIndexChange,
|
|
64
|
+
elementsRef,
|
|
65
|
+
onMapChange: onMapChangeUnwrapped,
|
|
66
|
+
relayKeyboardEvent
|
|
67
|
+
} = (0, import_useCompositeRoot.useCompositeRoot)(
|
|
68
|
+
{
|
|
69
|
+
grid,
|
|
70
|
+
loopFocus,
|
|
71
|
+
onLoop,
|
|
72
|
+
orientation,
|
|
73
|
+
highlightedIndex: highlightedIndexProp,
|
|
74
|
+
onHighlightedIndexChange: onHighlightedIndexChangeProp,
|
|
75
|
+
rootRef,
|
|
76
|
+
stopEventPropagation,
|
|
77
|
+
enableHomeAndEndKeys,
|
|
78
|
+
direction,
|
|
79
|
+
disabledIndices,
|
|
80
|
+
modifierKeys
|
|
81
|
+
},
|
|
82
|
+
(0, import_internal.subSlot)(slot, "root")
|
|
83
|
+
);
|
|
84
|
+
const element = (0, import_useRenderElement.useRenderElement)(
|
|
85
|
+
tag,
|
|
86
|
+
{ render, className, style },
|
|
87
|
+
{
|
|
88
|
+
state,
|
|
89
|
+
ref: refs,
|
|
90
|
+
props: [defaultProps, ...props, elementProps],
|
|
91
|
+
stateAttributesMapping
|
|
92
|
+
},
|
|
93
|
+
(0, import_internal.subSlot)(slot, "re")
|
|
94
|
+
);
|
|
95
|
+
const contextValue = (0, import_octane.useMemo)(
|
|
96
|
+
() => ({
|
|
97
|
+
highlightedIndex,
|
|
98
|
+
onHighlightedIndexChange,
|
|
99
|
+
highlightItemOnHover,
|
|
100
|
+
relayKeyboardEvent
|
|
101
|
+
}),
|
|
102
|
+
[highlightedIndex, onHighlightedIndexChange, highlightItemOnHover, relayKeyboardEvent],
|
|
103
|
+
(0, import_internal.subSlot)(slot, "ctx")
|
|
104
|
+
);
|
|
105
|
+
const list = (0, import_octane.createElement)(import_CompositeList.CompositeList, {
|
|
106
|
+
elementsRef,
|
|
107
|
+
onMapChange: (newMap) => {
|
|
108
|
+
onMapChangeProp?.(newMap);
|
|
109
|
+
onMapChangeUnwrapped(newMap);
|
|
110
|
+
},
|
|
111
|
+
children: element
|
|
112
|
+
});
|
|
113
|
+
return (0, import_octane.createElement)(import_CompositeRootContext.CompositeRootContext.Provider, { value: contextValue, children: list });
|
|
114
|
+
}
|
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
+
0 && (module.exports = {
|
|
117
|
+
CompositeRoot
|
|
118
|
+
});
|
|
@@ -0,0 +1,343 @@
|
|
|
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 grid_utils_exports = {};
|
|
20
|
+
__export(grid_utils_exports, {
|
|
21
|
+
createGridCellMap: () => createGridCellMap,
|
|
22
|
+
getGridCellIndexOfCorner: () => getGridCellIndexOfCorner,
|
|
23
|
+
getGridCellIndices: () => getGridCellIndices,
|
|
24
|
+
getGridNavigatedIndex: () => getGridNavigatedIndex
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(grid_utils_exports);
|
|
27
|
+
var import_utils = require("@floating-ui/utils");
|
|
28
|
+
var import_keys = require("./keys.cjs");
|
|
29
|
+
var import_list_utils = require("./list-utils.cjs");
|
|
30
|
+
function getGridNavigatedIndex(list, {
|
|
31
|
+
event,
|
|
32
|
+
orientation,
|
|
33
|
+
loopFocus,
|
|
34
|
+
onLoop,
|
|
35
|
+
rtl,
|
|
36
|
+
cols,
|
|
37
|
+
disabledIndices,
|
|
38
|
+
minIndex,
|
|
39
|
+
maxIndex,
|
|
40
|
+
prevIndex,
|
|
41
|
+
stopEvent: stop = false
|
|
42
|
+
}) {
|
|
43
|
+
let nextIndex = prevIndex;
|
|
44
|
+
let verticalDirection;
|
|
45
|
+
if (event.key === import_keys.ARROW_UP) {
|
|
46
|
+
verticalDirection = "up";
|
|
47
|
+
} else if (event.key === import_keys.ARROW_DOWN) {
|
|
48
|
+
verticalDirection = "down";
|
|
49
|
+
}
|
|
50
|
+
if (verticalDirection) {
|
|
51
|
+
const rows = [];
|
|
52
|
+
const rowIndexMap = [];
|
|
53
|
+
let hasRoleRow = false;
|
|
54
|
+
let visibleItemCount = 0;
|
|
55
|
+
{
|
|
56
|
+
let currentRowEl = null;
|
|
57
|
+
let currentRowIndex = -1;
|
|
58
|
+
list.forEach((el, idx) => {
|
|
59
|
+
if (el == null) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
visibleItemCount += 1;
|
|
63
|
+
const rowEl = el.closest('[role="row"]');
|
|
64
|
+
if (rowEl) {
|
|
65
|
+
hasRoleRow = true;
|
|
66
|
+
}
|
|
67
|
+
if (rowEl !== currentRowEl || currentRowIndex === -1) {
|
|
68
|
+
currentRowEl = rowEl;
|
|
69
|
+
currentRowIndex += 1;
|
|
70
|
+
rows[currentRowIndex] = [];
|
|
71
|
+
}
|
|
72
|
+
rows[currentRowIndex].push(idx);
|
|
73
|
+
rowIndexMap[idx] = currentRowIndex;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
let hasDomRows = false;
|
|
77
|
+
let inferredDomCols = 0;
|
|
78
|
+
if (hasRoleRow) {
|
|
79
|
+
for (const row of rows) {
|
|
80
|
+
const rowLength = row.length;
|
|
81
|
+
if (rowLength > inferredDomCols) {
|
|
82
|
+
inferredDomCols = rowLength;
|
|
83
|
+
}
|
|
84
|
+
if (rowLength !== cols) {
|
|
85
|
+
hasDomRows = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const hasVirtualizedGaps = hasDomRows && visibleItemCount < list.length;
|
|
90
|
+
const verticalCols = inferredDomCols || cols;
|
|
91
|
+
const navigateVertically = (direction) => {
|
|
92
|
+
if (!hasDomRows || prevIndex === -1) {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
const currentRow = rowIndexMap[prevIndex];
|
|
96
|
+
if (currentRow == null) {
|
|
97
|
+
return void 0;
|
|
98
|
+
}
|
|
99
|
+
const colInRow = rows[currentRow].indexOf(prevIndex);
|
|
100
|
+
const step = direction === "up" ? -1 : 1;
|
|
101
|
+
for (let nextRow = currentRow + step, i = 0; i < rows.length; i += 1, nextRow += step) {
|
|
102
|
+
if (nextRow < 0 || nextRow >= rows.length) {
|
|
103
|
+
if (!loopFocus || hasVirtualizedGaps) {
|
|
104
|
+
return void 0;
|
|
105
|
+
}
|
|
106
|
+
nextRow = nextRow < 0 ? rows.length - 1 : 0;
|
|
107
|
+
if (onLoop) {
|
|
108
|
+
const clampedCol = Math.min(colInRow, rows[nextRow].length - 1);
|
|
109
|
+
const targetItemIndex = rows[nextRow][clampedCol] ?? rows[nextRow][0];
|
|
110
|
+
const returnedItemIndex = onLoop(event, prevIndex, targetItemIndex);
|
|
111
|
+
nextRow = rowIndexMap[returnedItemIndex] ?? nextRow;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const targetRow = rows[nextRow];
|
|
115
|
+
for (let col = Math.min(colInRow, targetRow.length - 1); col >= 0; col -= 1) {
|
|
116
|
+
const candidate = targetRow[col];
|
|
117
|
+
if (!(0, import_list_utils.isListIndexDisabled)(list, candidate, disabledIndices)) {
|
|
118
|
+
return candidate;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return void 0;
|
|
123
|
+
};
|
|
124
|
+
const navigateVerticallyWithInferredRows = (direction) => {
|
|
125
|
+
if (!hasVirtualizedGaps || prevIndex === -1) {
|
|
126
|
+
return void 0;
|
|
127
|
+
}
|
|
128
|
+
const colInRow = prevIndex % verticalCols;
|
|
129
|
+
const rowStep = direction === "up" ? -verticalCols : verticalCols;
|
|
130
|
+
const lastRowStart = maxIndex - maxIndex % verticalCols;
|
|
131
|
+
const rowCount = (0, import_utils.floor)(maxIndex / verticalCols) + 1;
|
|
132
|
+
for (let rowStart = prevIndex - colInRow + rowStep, i = 0; i < rowCount; i += 1, rowStart += rowStep) {
|
|
133
|
+
if (rowStart < 0 || rowStart > maxIndex) {
|
|
134
|
+
if (!loopFocus) {
|
|
135
|
+
return void 0;
|
|
136
|
+
}
|
|
137
|
+
rowStart = rowStart < 0 ? lastRowStart : 0;
|
|
138
|
+
}
|
|
139
|
+
const rowEnd = Math.min(rowStart + verticalCols - 1, maxIndex);
|
|
140
|
+
for (let candidate = Math.min(rowStart + colInRow, rowEnd); candidate >= rowStart; candidate -= 1) {
|
|
141
|
+
if (!(0, import_list_utils.isListIndexDisabled)(list, candidate, disabledIndices)) {
|
|
142
|
+
return candidate;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return void 0;
|
|
147
|
+
};
|
|
148
|
+
if (stop) {
|
|
149
|
+
(0, import_list_utils.stopEvent)(event);
|
|
150
|
+
}
|
|
151
|
+
const verticalCandidate = navigateVertically(verticalDirection) ?? navigateVerticallyWithInferredRows(verticalDirection);
|
|
152
|
+
if (verticalCandidate !== void 0) {
|
|
153
|
+
nextIndex = verticalCandidate;
|
|
154
|
+
} else if (prevIndex === -1) {
|
|
155
|
+
nextIndex = verticalDirection === "up" ? maxIndex : minIndex;
|
|
156
|
+
} else {
|
|
157
|
+
nextIndex = (0, import_list_utils.findNonDisabledListIndex)(list, {
|
|
158
|
+
startingIndex: prevIndex,
|
|
159
|
+
amount: verticalCols,
|
|
160
|
+
decrement: verticalDirection === "up",
|
|
161
|
+
disabledIndices
|
|
162
|
+
});
|
|
163
|
+
if (loopFocus) {
|
|
164
|
+
if (verticalDirection === "up" && (prevIndex - verticalCols < minIndex || nextIndex < 0)) {
|
|
165
|
+
const col = prevIndex % verticalCols;
|
|
166
|
+
const maxCol = maxIndex % verticalCols;
|
|
167
|
+
const offset = maxIndex - (maxCol - col);
|
|
168
|
+
if (maxCol === col) {
|
|
169
|
+
nextIndex = maxIndex;
|
|
170
|
+
} else {
|
|
171
|
+
nextIndex = maxCol > col ? offset : offset - verticalCols;
|
|
172
|
+
}
|
|
173
|
+
if (onLoop) {
|
|
174
|
+
nextIndex = onLoop(event, prevIndex, nextIndex);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (verticalDirection === "down" && prevIndex + verticalCols > maxIndex) {
|
|
178
|
+
nextIndex = (0, import_list_utils.findNonDisabledListIndex)(list, {
|
|
179
|
+
startingIndex: prevIndex % verticalCols - verticalCols,
|
|
180
|
+
amount: verticalCols,
|
|
181
|
+
disabledIndices
|
|
182
|
+
});
|
|
183
|
+
if (onLoop) {
|
|
184
|
+
nextIndex = onLoop(event, prevIndex, nextIndex);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if ((0, import_list_utils.isIndexOutOfListBounds)(list, nextIndex)) {
|
|
190
|
+
nextIndex = prevIndex;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (orientation === "both") {
|
|
194
|
+
const prevRow = (0, import_utils.floor)(prevIndex / cols);
|
|
195
|
+
if (event.key === (rtl ? import_keys.ARROW_LEFT : import_keys.ARROW_RIGHT)) {
|
|
196
|
+
if (stop) {
|
|
197
|
+
(0, import_list_utils.stopEvent)(event);
|
|
198
|
+
}
|
|
199
|
+
if (prevIndex % cols !== cols - 1) {
|
|
200
|
+
nextIndex = (0, import_list_utils.findNonDisabledListIndex)(list, {
|
|
201
|
+
startingIndex: prevIndex,
|
|
202
|
+
disabledIndices
|
|
203
|
+
});
|
|
204
|
+
if (loopFocus && (0, import_list_utils.isDifferentGridRow)(nextIndex, cols, prevRow)) {
|
|
205
|
+
nextIndex = (0, import_list_utils.findNonDisabledListIndex)(list, {
|
|
206
|
+
startingIndex: prevIndex - prevIndex % cols - 1,
|
|
207
|
+
disabledIndices
|
|
208
|
+
});
|
|
209
|
+
if (onLoop) {
|
|
210
|
+
nextIndex = onLoop(event, prevIndex, nextIndex);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} else if (loopFocus) {
|
|
214
|
+
nextIndex = (0, import_list_utils.findNonDisabledListIndex)(list, {
|
|
215
|
+
startingIndex: prevIndex - prevIndex % cols - 1,
|
|
216
|
+
disabledIndices
|
|
217
|
+
});
|
|
218
|
+
if (onLoop) {
|
|
219
|
+
nextIndex = onLoop(event, prevIndex, nextIndex);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if ((0, import_list_utils.isDifferentGridRow)(nextIndex, cols, prevRow)) {
|
|
223
|
+
nextIndex = prevIndex;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (event.key === (rtl ? import_keys.ARROW_RIGHT : import_keys.ARROW_LEFT)) {
|
|
227
|
+
if (stop) {
|
|
228
|
+
(0, import_list_utils.stopEvent)(event);
|
|
229
|
+
}
|
|
230
|
+
if (prevIndex % cols !== 0) {
|
|
231
|
+
nextIndex = (0, import_list_utils.findNonDisabledListIndex)(list, {
|
|
232
|
+
startingIndex: prevIndex,
|
|
233
|
+
decrement: true,
|
|
234
|
+
disabledIndices
|
|
235
|
+
});
|
|
236
|
+
if (loopFocus && (0, import_list_utils.isDifferentGridRow)(nextIndex, cols, prevRow)) {
|
|
237
|
+
nextIndex = (0, import_list_utils.findNonDisabledListIndex)(list, {
|
|
238
|
+
startingIndex: prevIndex + (cols - prevIndex % cols),
|
|
239
|
+
decrement: true,
|
|
240
|
+
disabledIndices
|
|
241
|
+
});
|
|
242
|
+
if (onLoop) {
|
|
243
|
+
nextIndex = onLoop(event, prevIndex, nextIndex);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
} else if (loopFocus) {
|
|
247
|
+
nextIndex = (0, import_list_utils.findNonDisabledListIndex)(list, {
|
|
248
|
+
startingIndex: prevIndex + (cols - prevIndex % cols),
|
|
249
|
+
decrement: true,
|
|
250
|
+
disabledIndices
|
|
251
|
+
});
|
|
252
|
+
if (onLoop) {
|
|
253
|
+
nextIndex = onLoop(event, prevIndex, nextIndex);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if ((0, import_list_utils.isDifferentGridRow)(nextIndex, cols, prevRow)) {
|
|
257
|
+
nextIndex = prevIndex;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const lastRow = (0, import_utils.floor)(maxIndex / cols) === prevRow;
|
|
261
|
+
if ((0, import_list_utils.isIndexOutOfListBounds)(list, nextIndex)) {
|
|
262
|
+
if (loopFocus && lastRow) {
|
|
263
|
+
nextIndex = event.key === (rtl ? import_keys.ARROW_RIGHT : import_keys.ARROW_LEFT) ? maxIndex : (0, import_list_utils.findNonDisabledListIndex)(list, {
|
|
264
|
+
startingIndex: prevIndex - prevIndex % cols - 1,
|
|
265
|
+
disabledIndices
|
|
266
|
+
});
|
|
267
|
+
if (onLoop) {
|
|
268
|
+
nextIndex = onLoop(event, prevIndex, nextIndex);
|
|
269
|
+
}
|
|
270
|
+
} else {
|
|
271
|
+
nextIndex = prevIndex;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return nextIndex;
|
|
276
|
+
}
|
|
277
|
+
function createGridCellMap(sizes, cols, dense) {
|
|
278
|
+
const cellMap = [];
|
|
279
|
+
let startIndex = 0;
|
|
280
|
+
sizes.forEach(({ width, height }, index) => {
|
|
281
|
+
if (width > cols) {
|
|
282
|
+
throw new Error(
|
|
283
|
+
`[Floating UI]: Invalid grid - item width at index ${index} is greater than grid columns`
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
let itemPlaced = false;
|
|
287
|
+
if (dense) {
|
|
288
|
+
startIndex = 0;
|
|
289
|
+
}
|
|
290
|
+
while (!itemPlaced) {
|
|
291
|
+
const targetCells = [];
|
|
292
|
+
for (let i = 0; i < width; i += 1) {
|
|
293
|
+
for (let j = 0; j < height; j += 1) {
|
|
294
|
+
targetCells.push(startIndex + i + j * cols);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (startIndex % cols + width <= cols && targetCells.every((cell) => cellMap[cell] == null)) {
|
|
298
|
+
targetCells.forEach((cell) => {
|
|
299
|
+
cellMap[cell] = index;
|
|
300
|
+
});
|
|
301
|
+
itemPlaced = true;
|
|
302
|
+
} else {
|
|
303
|
+
startIndex += 1;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
return [...cellMap];
|
|
308
|
+
}
|
|
309
|
+
function getGridCellIndexOfCorner(index, sizes, cellMap, cols, corner) {
|
|
310
|
+
if (index === -1) {
|
|
311
|
+
return -1;
|
|
312
|
+
}
|
|
313
|
+
const firstCellIndex = cellMap.indexOf(index);
|
|
314
|
+
const sizeItem = sizes[index];
|
|
315
|
+
switch (corner) {
|
|
316
|
+
case "tl":
|
|
317
|
+
return firstCellIndex;
|
|
318
|
+
case "tr":
|
|
319
|
+
if (!sizeItem) {
|
|
320
|
+
return firstCellIndex;
|
|
321
|
+
}
|
|
322
|
+
return firstCellIndex + sizeItem.width - 1;
|
|
323
|
+
case "bl":
|
|
324
|
+
if (!sizeItem) {
|
|
325
|
+
return firstCellIndex;
|
|
326
|
+
}
|
|
327
|
+
return firstCellIndex + (sizeItem.height - 1) * cols;
|
|
328
|
+
case "br":
|
|
329
|
+
return cellMap.lastIndexOf(index);
|
|
330
|
+
default:
|
|
331
|
+
return -1;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function getGridCellIndices(indices, cellMap) {
|
|
335
|
+
return cellMap.flatMap((index, cellIndex) => indices.includes(index) ? [cellIndex] : []);
|
|
336
|
+
}
|
|
337
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
338
|
+
0 && (module.exports = {
|
|
339
|
+
createGridCellMap,
|
|
340
|
+
getGridCellIndexOfCorner,
|
|
341
|
+
getGridCellIndices,
|
|
342
|
+
getGridNavigatedIndex
|
|
343
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
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 gridNavigation_exports = {};
|
|
20
|
+
__export(gridNavigation_exports, {
|
|
21
|
+
gridNavigation: () => gridNavigation
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(gridNavigation_exports);
|
|
24
|
+
var import_grid_utils = require("./grid-utils.cjs");
|
|
25
|
+
var import_list_utils = require("./list-utils.cjs");
|
|
26
|
+
var import_keys = require("./keys.cjs");
|
|
27
|
+
function gridNavigation(config) {
|
|
28
|
+
const { cols, dense = false, itemSizes } = config;
|
|
29
|
+
return (state) => {
|
|
30
|
+
const {
|
|
31
|
+
disabledIndices,
|
|
32
|
+
elementsRef,
|
|
33
|
+
event,
|
|
34
|
+
highlightedIndex,
|
|
35
|
+
loopFocus,
|
|
36
|
+
maxIndex,
|
|
37
|
+
minIndex,
|
|
38
|
+
onLoop,
|
|
39
|
+
orientation,
|
|
40
|
+
rtl
|
|
41
|
+
} = state;
|
|
42
|
+
const sizes = itemSizes || Array.from({ length: elementsRef.current.length }, () => ({
|
|
43
|
+
width: 1,
|
|
44
|
+
height: 1
|
|
45
|
+
}));
|
|
46
|
+
const cellMap = (0, import_grid_utils.createGridCellMap)(sizes, cols, dense);
|
|
47
|
+
const minGridIndex = cellMap.findIndex(
|
|
48
|
+
(index) => index != null && !(0, import_list_utils.isListIndexDisabled)(elementsRef.current, index, disabledIndices)
|
|
49
|
+
);
|
|
50
|
+
const maxGridIndex = cellMap.reduce(
|
|
51
|
+
(foundIndex, index, cellIndex2) => index != null && !(0, import_list_utils.isListIndexDisabled)(elementsRef.current, index, disabledIndices) ? cellIndex2 : foundIndex,
|
|
52
|
+
-1
|
|
53
|
+
);
|
|
54
|
+
const cellIndex = (0, import_grid_utils.getGridNavigatedIndex)(
|
|
55
|
+
cellMap.map((itemIndex) => itemIndex != null ? elementsRef.current[itemIndex] : null),
|
|
56
|
+
{
|
|
57
|
+
event,
|
|
58
|
+
orientation,
|
|
59
|
+
loopFocus,
|
|
60
|
+
onLoop,
|
|
61
|
+
cols,
|
|
62
|
+
// Treat undefined gaps as disabled so navigation cannot land in them.
|
|
63
|
+
disabledIndices: (0, import_grid_utils.getGridCellIndices)(
|
|
64
|
+
[
|
|
65
|
+
...disabledIndices || elementsRef.current.map(
|
|
66
|
+
(_, index) => (0, import_list_utils.isListIndexDisabled)(elementsRef.current, index) ? index : void 0
|
|
67
|
+
),
|
|
68
|
+
void 0
|
|
69
|
+
],
|
|
70
|
+
cellMap
|
|
71
|
+
),
|
|
72
|
+
minIndex: minGridIndex,
|
|
73
|
+
maxIndex: maxGridIndex,
|
|
74
|
+
prevIndex: (0, import_grid_utils.getGridCellIndexOfCorner)(
|
|
75
|
+
highlightedIndex > maxIndex ? minIndex : highlightedIndex,
|
|
76
|
+
sizes,
|
|
77
|
+
cellMap,
|
|
78
|
+
cols,
|
|
79
|
+
// Choose the corner closest to the movement direction so spanning items
|
|
80
|
+
// do not immediately resolve back to themselves.
|
|
81
|
+
event.key === import_keys.ARROW_DOWN ? "bl" : event.key === (rtl ? import_keys.ARROW_LEFT : import_keys.ARROW_RIGHT) ? "tr" : "tl"
|
|
82
|
+
),
|
|
83
|
+
rtl
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
return cellMap[cellIndex];
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
gridNavigation
|
|
92
|
+
});
|