@octanejs/base-ui 0.1.31 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,301 @@
|
|
|
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 safePolygon_exports = {};
|
|
20
|
+
__export(safePolygon_exports, {
|
|
21
|
+
safePolygon: () => safePolygon
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(safePolygon_exports);
|
|
24
|
+
var import_dom = require("../dom.cjs");
|
|
25
|
+
var import_useTimeout = require("../useTimeout.cjs");
|
|
26
|
+
var import_element = require("./element.cjs");
|
|
27
|
+
var import_nodes = require("./nodes.cjs");
|
|
28
|
+
const CURSOR_SPEED_THRESHOLD = 0.1;
|
|
29
|
+
const CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
|
|
30
|
+
const POLYGON_BUFFER = 0.5;
|
|
31
|
+
function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
|
|
32
|
+
return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
|
|
33
|
+
}
|
|
34
|
+
function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
|
|
35
|
+
let isInsideValue = false;
|
|
36
|
+
if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
|
|
37
|
+
isInsideValue = !isInsideValue;
|
|
38
|
+
}
|
|
39
|
+
if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
|
|
40
|
+
isInsideValue = !isInsideValue;
|
|
41
|
+
}
|
|
42
|
+
if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
|
|
43
|
+
isInsideValue = !isInsideValue;
|
|
44
|
+
}
|
|
45
|
+
if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
|
|
46
|
+
isInsideValue = !isInsideValue;
|
|
47
|
+
}
|
|
48
|
+
return isInsideValue;
|
|
49
|
+
}
|
|
50
|
+
function isInsideRect(pointX, pointY, rect) {
|
|
51
|
+
return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
|
|
52
|
+
}
|
|
53
|
+
function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
|
|
54
|
+
const minX = Math.min(x1, x2);
|
|
55
|
+
const maxX = Math.max(x1, x2);
|
|
56
|
+
const minY = Math.min(y1, y2);
|
|
57
|
+
const maxY = Math.max(y1, y2);
|
|
58
|
+
return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
|
|
59
|
+
}
|
|
60
|
+
function safePolygon(options = {}) {
|
|
61
|
+
const { blockPointerEvents = false } = options;
|
|
62
|
+
const timeout = new import_useTimeout.Timeout();
|
|
63
|
+
const fn = ({ x, y, placement, elements, onClose, nodeId, tree }) => {
|
|
64
|
+
const side = placement?.split("-")[0];
|
|
65
|
+
let hasLanded = false;
|
|
66
|
+
let lastX = null;
|
|
67
|
+
let lastY = null;
|
|
68
|
+
let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
|
|
69
|
+
function isCursorMovingSlowly(nextX, nextY) {
|
|
70
|
+
const currentTime = performance.now();
|
|
71
|
+
const elapsedTime = currentTime - lastCursorTime;
|
|
72
|
+
if (lastX === null || lastY === null || elapsedTime === 0) {
|
|
73
|
+
lastX = nextX;
|
|
74
|
+
lastY = nextY;
|
|
75
|
+
lastCursorTime = currentTime;
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const deltaX = nextX - lastX;
|
|
79
|
+
const deltaY = nextY - lastY;
|
|
80
|
+
const distanceSquared = deltaX * deltaX + deltaY * deltaY;
|
|
81
|
+
const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
|
|
82
|
+
lastX = nextX;
|
|
83
|
+
lastY = nextY;
|
|
84
|
+
lastCursorTime = currentTime;
|
|
85
|
+
return distanceSquared < thresholdSquared;
|
|
86
|
+
}
|
|
87
|
+
function close() {
|
|
88
|
+
timeout.clear();
|
|
89
|
+
onClose();
|
|
90
|
+
}
|
|
91
|
+
return function onMouseMove(event) {
|
|
92
|
+
timeout.clear();
|
|
93
|
+
const domReference = elements.domReference;
|
|
94
|
+
const floating = elements.floating;
|
|
95
|
+
if (!domReference || !floating || side == null || x == null || y == null) {
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
const { clientX, clientY } = event;
|
|
99
|
+
const target = (0, import_element.getTarget)(event);
|
|
100
|
+
const isLeave = event.type === "mouseleave";
|
|
101
|
+
const isOverFloatingEl = (0, import_element.contains)(floating, target);
|
|
102
|
+
const isOverReferenceEl = (0, import_element.contains)(domReference, target);
|
|
103
|
+
if (isOverFloatingEl) {
|
|
104
|
+
hasLanded = true;
|
|
105
|
+
if (!isLeave) {
|
|
106
|
+
return void 0;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (isOverReferenceEl) {
|
|
110
|
+
hasLanded = false;
|
|
111
|
+
if (!isLeave) {
|
|
112
|
+
hasLanded = true;
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (isLeave && (0, import_dom.isElement)(event.relatedTarget) && (0, import_element.contains)(floating, event.relatedTarget)) {
|
|
117
|
+
return void 0;
|
|
118
|
+
}
|
|
119
|
+
function hasOpenChildNode() {
|
|
120
|
+
return Boolean(tree && (0, import_nodes.getNodeChildren)(tree.nodesRef.current, nodeId).length > 0);
|
|
121
|
+
}
|
|
122
|
+
function closeIfNoOpenChild() {
|
|
123
|
+
if (!hasOpenChildNode()) {
|
|
124
|
+
close();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (hasOpenChildNode()) {
|
|
128
|
+
return void 0;
|
|
129
|
+
}
|
|
130
|
+
const refRect = domReference.getBoundingClientRect();
|
|
131
|
+
const rect = floating.getBoundingClientRect();
|
|
132
|
+
const cursorLeaveFromRight = x > rect.right - rect.width / 2;
|
|
133
|
+
const cursorLeaveFromBottom = y > rect.bottom - rect.height / 2;
|
|
134
|
+
const isFloatingWider = rect.width > refRect.width;
|
|
135
|
+
const isFloatingTaller = rect.height > refRect.height;
|
|
136
|
+
const left = (isFloatingWider ? refRect : rect).left;
|
|
137
|
+
const right = (isFloatingWider ? refRect : rect).right;
|
|
138
|
+
const top = (isFloatingTaller ? refRect : rect).top;
|
|
139
|
+
const bottom = (isFloatingTaller ? refRect : rect).bottom;
|
|
140
|
+
if (side === "top" && y >= refRect.bottom - 1 || side === "bottom" && y <= refRect.top + 1 || side === "left" && x >= refRect.right - 1 || side === "right" && x <= refRect.left + 1) {
|
|
141
|
+
closeIfNoOpenChild();
|
|
142
|
+
return void 0;
|
|
143
|
+
}
|
|
144
|
+
let isInsideTroughRect = false;
|
|
145
|
+
switch (side) {
|
|
146
|
+
case "top":
|
|
147
|
+
isInsideTroughRect = isInsideAxisAlignedRect(
|
|
148
|
+
clientX,
|
|
149
|
+
clientY,
|
|
150
|
+
left,
|
|
151
|
+
refRect.top + 1,
|
|
152
|
+
right,
|
|
153
|
+
rect.bottom - 1
|
|
154
|
+
);
|
|
155
|
+
break;
|
|
156
|
+
case "bottom":
|
|
157
|
+
isInsideTroughRect = isInsideAxisAlignedRect(
|
|
158
|
+
clientX,
|
|
159
|
+
clientY,
|
|
160
|
+
left,
|
|
161
|
+
rect.top + 1,
|
|
162
|
+
right,
|
|
163
|
+
refRect.bottom - 1
|
|
164
|
+
);
|
|
165
|
+
break;
|
|
166
|
+
case "left":
|
|
167
|
+
isInsideTroughRect = isInsideAxisAlignedRect(
|
|
168
|
+
clientX,
|
|
169
|
+
clientY,
|
|
170
|
+
rect.right - 1,
|
|
171
|
+
bottom,
|
|
172
|
+
refRect.left + 1,
|
|
173
|
+
top
|
|
174
|
+
);
|
|
175
|
+
break;
|
|
176
|
+
case "right":
|
|
177
|
+
isInsideTroughRect = isInsideAxisAlignedRect(
|
|
178
|
+
clientX,
|
|
179
|
+
clientY,
|
|
180
|
+
refRect.right - 1,
|
|
181
|
+
bottom,
|
|
182
|
+
rect.left + 1,
|
|
183
|
+
top
|
|
184
|
+
);
|
|
185
|
+
break;
|
|
186
|
+
default:
|
|
187
|
+
}
|
|
188
|
+
if (isInsideTroughRect) {
|
|
189
|
+
return void 0;
|
|
190
|
+
}
|
|
191
|
+
if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
|
|
192
|
+
closeIfNoOpenChild();
|
|
193
|
+
return void 0;
|
|
194
|
+
}
|
|
195
|
+
if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
|
|
196
|
+
closeIfNoOpenChild();
|
|
197
|
+
return void 0;
|
|
198
|
+
}
|
|
199
|
+
let isInsidePolygon = false;
|
|
200
|
+
switch (side) {
|
|
201
|
+
case "top": {
|
|
202
|
+
const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
|
|
203
|
+
const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
|
|
204
|
+
const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
|
|
205
|
+
const cursorPointY = y + POLYGON_BUFFER + 1;
|
|
206
|
+
const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
|
|
207
|
+
const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
|
|
208
|
+
isInsidePolygon = isPointInQuadrilateral(
|
|
209
|
+
clientX,
|
|
210
|
+
clientY,
|
|
211
|
+
cursorPointOneX,
|
|
212
|
+
cursorPointY,
|
|
213
|
+
cursorPointTwoX,
|
|
214
|
+
cursorPointY,
|
|
215
|
+
rect.left,
|
|
216
|
+
commonYLeft,
|
|
217
|
+
rect.right,
|
|
218
|
+
commonYRight
|
|
219
|
+
);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
case "bottom": {
|
|
223
|
+
const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
|
|
224
|
+
const cursorPointOneX = isFloatingWider ? x + cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
|
|
225
|
+
const cursorPointTwoX = isFloatingWider ? x - cursorXOffset : cursorLeaveFromRight ? x + cursorXOffset : x - cursorXOffset;
|
|
226
|
+
const cursorPointY = y - POLYGON_BUFFER;
|
|
227
|
+
const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
|
|
228
|
+
const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
|
|
229
|
+
isInsidePolygon = isPointInQuadrilateral(
|
|
230
|
+
clientX,
|
|
231
|
+
clientY,
|
|
232
|
+
cursorPointOneX,
|
|
233
|
+
cursorPointY,
|
|
234
|
+
cursorPointTwoX,
|
|
235
|
+
cursorPointY,
|
|
236
|
+
rect.left,
|
|
237
|
+
commonYLeft,
|
|
238
|
+
rect.right,
|
|
239
|
+
commonYRight
|
|
240
|
+
);
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
case "left": {
|
|
244
|
+
const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
|
|
245
|
+
const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
|
|
246
|
+
const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
|
|
247
|
+
const cursorPointX = x + POLYGON_BUFFER + 1;
|
|
248
|
+
const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
|
|
249
|
+
const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
|
|
250
|
+
isInsidePolygon = isPointInQuadrilateral(
|
|
251
|
+
clientX,
|
|
252
|
+
clientY,
|
|
253
|
+
commonXTop,
|
|
254
|
+
rect.top,
|
|
255
|
+
commonXBottom,
|
|
256
|
+
rect.bottom,
|
|
257
|
+
cursorPointX,
|
|
258
|
+
cursorPointOneY,
|
|
259
|
+
cursorPointX,
|
|
260
|
+
cursorPointTwoY
|
|
261
|
+
);
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
case "right": {
|
|
265
|
+
const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
|
|
266
|
+
const cursorPointOneY = isFloatingTaller ? y + cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
|
|
267
|
+
const cursorPointTwoY = isFloatingTaller ? y - cursorYOffset : cursorLeaveFromBottom ? y + cursorYOffset : y - cursorYOffset;
|
|
268
|
+
const cursorPointX = x - POLYGON_BUFFER;
|
|
269
|
+
const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
|
|
270
|
+
const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
|
|
271
|
+
isInsidePolygon = isPointInQuadrilateral(
|
|
272
|
+
clientX,
|
|
273
|
+
clientY,
|
|
274
|
+
cursorPointX,
|
|
275
|
+
cursorPointOneY,
|
|
276
|
+
cursorPointX,
|
|
277
|
+
cursorPointTwoY,
|
|
278
|
+
commonXTop,
|
|
279
|
+
rect.top,
|
|
280
|
+
commonXBottom,
|
|
281
|
+
rect.bottom
|
|
282
|
+
);
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
default:
|
|
286
|
+
}
|
|
287
|
+
if (!isInsidePolygon) {
|
|
288
|
+
closeIfNoOpenChild();
|
|
289
|
+
} else if (!hasLanded) {
|
|
290
|
+
timeout.start(40, closeIfNoOpenChild);
|
|
291
|
+
}
|
|
292
|
+
return void 0;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
fn.__options = { ...options, blockPointerEvents };
|
|
296
|
+
return fn;
|
|
297
|
+
}
|
|
298
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
299
|
+
0 && (module.exports = {
|
|
300
|
+
safePolygon
|
|
301
|
+
});
|
|
@@ -0,0 +1,242 @@
|
|
|
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 tabbable_exports = {};
|
|
20
|
+
__export(tabbable_exports, {
|
|
21
|
+
disableFocusInside: () => disableFocusInside,
|
|
22
|
+
enableFocusInside: () => enableFocusInside,
|
|
23
|
+
focusable: () => focusable,
|
|
24
|
+
getNextTabbable: () => getNextTabbable,
|
|
25
|
+
getPreviousTabbable: () => getPreviousTabbable,
|
|
26
|
+
getTabbableAfterElement: () => getTabbableAfterElement,
|
|
27
|
+
getTabbableBeforeElement: () => getTabbableBeforeElement,
|
|
28
|
+
isOutsideEvent: () => isOutsideEvent,
|
|
29
|
+
isTabbable: () => isTabbable,
|
|
30
|
+
tabbable: () => tabbable
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(tabbable_exports);
|
|
33
|
+
var import_dom = require("@floating-ui/utils/dom");
|
|
34
|
+
var import_owner = require("../owner.cjs");
|
|
35
|
+
var import_element = require("./element.cjs");
|
|
36
|
+
var import_composite = require("./composite.cjs");
|
|
37
|
+
const CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
|
|
38
|
+
function getParentElement(element) {
|
|
39
|
+
const assignedSlot = element.assignedSlot;
|
|
40
|
+
if (assignedSlot) {
|
|
41
|
+
return assignedSlot;
|
|
42
|
+
}
|
|
43
|
+
if (element.parentElement) {
|
|
44
|
+
return element.parentElement;
|
|
45
|
+
}
|
|
46
|
+
const rootNode = element.getRootNode();
|
|
47
|
+
return (0, import_dom.isShadowRoot)(rootNode) ? rootNode.host : null;
|
|
48
|
+
}
|
|
49
|
+
function getDetailsSummary(details) {
|
|
50
|
+
for (const child of Array.from(details.children)) {
|
|
51
|
+
if ((0, import_dom.getNodeName)(child) === "summary") {
|
|
52
|
+
return child;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function isWithinOpenDetailsSummary(element, details) {
|
|
58
|
+
const summary = getDetailsSummary(details);
|
|
59
|
+
return !!summary && (element === summary || (0, import_element.contains)(summary, element));
|
|
60
|
+
}
|
|
61
|
+
function isFocusableCandidate(element) {
|
|
62
|
+
const nodeName = element ? (0, import_dom.getNodeName)(element) : "";
|
|
63
|
+
return element != null && element.matches(CANDIDATE_SELECTOR) && (nodeName !== "summary" || element.parentElement != null && (0, import_dom.getNodeName)(element.parentElement) === "details" && getDetailsSummary(element.parentElement) === element) && (nodeName !== "details" || getDetailsSummary(element) == null) && (nodeName !== "input" || element.type !== "hidden");
|
|
64
|
+
}
|
|
65
|
+
function isFocusableElement(element) {
|
|
66
|
+
if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
for (let current = element; current; current = getParentElement(current)) {
|
|
70
|
+
const isAncestor = current !== element;
|
|
71
|
+
const isSlot = (0, import_dom.getNodeName)(current) === "slot";
|
|
72
|
+
if (current.hasAttribute("inert")) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (isAncestor && (0, import_dom.getNodeName)(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
function isVisibleInTabbableTree(element, isAncestor) {
|
|
82
|
+
const styles = (0, import_dom.getComputedStyle)(element);
|
|
83
|
+
if (!isAncestor) {
|
|
84
|
+
return (0, import_composite.isElementVisible)(element, styles);
|
|
85
|
+
}
|
|
86
|
+
return styles.display !== "none";
|
|
87
|
+
}
|
|
88
|
+
function getTabIndex(element) {
|
|
89
|
+
const tabIndex = element.tabIndex;
|
|
90
|
+
if (tabIndex < 0) {
|
|
91
|
+
const nodeName = (0, import_dom.getNodeName)(element);
|
|
92
|
+
if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || (0, import_dom.isHTMLElement)(element) && element.isContentEditable) {
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return tabIndex;
|
|
97
|
+
}
|
|
98
|
+
function getNamedRadioInput(element) {
|
|
99
|
+
if ((0, import_dom.getNodeName)(element) !== "input") {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const input = element;
|
|
103
|
+
return input.type === "radio" && input.name !== "" ? input : null;
|
|
104
|
+
}
|
|
105
|
+
function isTabbableRadio(element, candidates) {
|
|
106
|
+
const input = getNamedRadioInput(element);
|
|
107
|
+
if (!input) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
const checkedRadio = candidates.find((candidate) => {
|
|
111
|
+
const radio = getNamedRadioInput(candidate);
|
|
112
|
+
return radio?.name === input.name && radio.form === input.form && radio.checked;
|
|
113
|
+
});
|
|
114
|
+
if (checkedRadio) {
|
|
115
|
+
return checkedRadio === input;
|
|
116
|
+
}
|
|
117
|
+
return candidates.find((candidate) => {
|
|
118
|
+
const radio = getNamedRadioInput(candidate);
|
|
119
|
+
return radio?.name === input.name && radio.form === input.form;
|
|
120
|
+
}) === input;
|
|
121
|
+
}
|
|
122
|
+
function getComposedChildren(container) {
|
|
123
|
+
if ((0, import_dom.isHTMLElement)(container) && (0, import_dom.getNodeName)(container) === "slot") {
|
|
124
|
+
const assignedElements = container.assignedElements({
|
|
125
|
+
flatten: true
|
|
126
|
+
});
|
|
127
|
+
if (assignedElements.length > 0) {
|
|
128
|
+
return assignedElements;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if ((0, import_dom.isHTMLElement)(container) && container.shadowRoot) {
|
|
132
|
+
return Array.from(container.shadowRoot.children);
|
|
133
|
+
}
|
|
134
|
+
return Array.from(container.children);
|
|
135
|
+
}
|
|
136
|
+
function appendCandidates(container, list) {
|
|
137
|
+
getComposedChildren(container).forEach((child) => {
|
|
138
|
+
if (isFocusableCandidate(child)) {
|
|
139
|
+
list.push(child);
|
|
140
|
+
}
|
|
141
|
+
appendCandidates(child, list);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function appendMatchingElements(container, selector, list) {
|
|
145
|
+
getComposedChildren(container).forEach((child) => {
|
|
146
|
+
if ((0, import_dom.isHTMLElement)(child) && child.matches(selector)) {
|
|
147
|
+
list.push(child);
|
|
148
|
+
}
|
|
149
|
+
appendMatchingElements(child, selector, list);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function isTabbable(element) {
|
|
153
|
+
return isFocusableElement(element) && getTabIndex(element) >= 0;
|
|
154
|
+
}
|
|
155
|
+
function focusable(container) {
|
|
156
|
+
const candidates = [];
|
|
157
|
+
appendCandidates(container, candidates);
|
|
158
|
+
return candidates.filter(isFocusableElement);
|
|
159
|
+
}
|
|
160
|
+
function tabbable(container) {
|
|
161
|
+
const candidates = focusable(container);
|
|
162
|
+
return candidates.filter(
|
|
163
|
+
(element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates)
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
function getTabbableIn(container, dir) {
|
|
167
|
+
const list = tabbable(container);
|
|
168
|
+
const len = list.length;
|
|
169
|
+
if (len === 0) {
|
|
170
|
+
return void 0;
|
|
171
|
+
}
|
|
172
|
+
const active = (0, import_element.activeElement)((0, import_owner.ownerDocument)(container));
|
|
173
|
+
const index = list.indexOf(active);
|
|
174
|
+
const nextIndex = index === -1 ? dir === 1 ? 0 : len - 1 : index + dir;
|
|
175
|
+
return list[nextIndex];
|
|
176
|
+
}
|
|
177
|
+
function getNextTabbable(referenceElement) {
|
|
178
|
+
return getTabbableIn((0, import_owner.ownerDocument)(referenceElement).body, 1) || referenceElement;
|
|
179
|
+
}
|
|
180
|
+
function getPreviousTabbable(referenceElement) {
|
|
181
|
+
return getTabbableIn((0, import_owner.ownerDocument)(referenceElement).body, -1) || referenceElement;
|
|
182
|
+
}
|
|
183
|
+
function getTabbableNearElement(referenceElement, dir) {
|
|
184
|
+
if (!referenceElement) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
const list = tabbable((0, import_owner.ownerDocument)(referenceElement).body);
|
|
188
|
+
const elementCount = list.length;
|
|
189
|
+
if (elementCount === 0) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
const index = list.indexOf(referenceElement);
|
|
193
|
+
if (index === -1) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
const nextIndex = (index + dir + elementCount) % elementCount;
|
|
197
|
+
return list[nextIndex];
|
|
198
|
+
}
|
|
199
|
+
function getTabbableAfterElement(referenceElement) {
|
|
200
|
+
return getTabbableNearElement(referenceElement, 1);
|
|
201
|
+
}
|
|
202
|
+
function getTabbableBeforeElement(referenceElement) {
|
|
203
|
+
return getTabbableNearElement(referenceElement, -1);
|
|
204
|
+
}
|
|
205
|
+
function isOutsideEvent(event, container) {
|
|
206
|
+
const containerElement = container || event.currentTarget;
|
|
207
|
+
const relatedTarget = event.relatedTarget;
|
|
208
|
+
return !relatedTarget || !(0, import_element.contains)(containerElement, relatedTarget);
|
|
209
|
+
}
|
|
210
|
+
function disableFocusInside(container) {
|
|
211
|
+
const tabbableElements = tabbable(container);
|
|
212
|
+
tabbableElements.forEach((element) => {
|
|
213
|
+
element.dataset.tabindex = element.getAttribute("tabindex") || "";
|
|
214
|
+
element.setAttribute("tabindex", "-1");
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function enableFocusInside(container) {
|
|
218
|
+
const elements = [];
|
|
219
|
+
appendMatchingElements(container, "[data-tabindex]", elements);
|
|
220
|
+
elements.forEach((element) => {
|
|
221
|
+
const tabindex = element.dataset.tabindex;
|
|
222
|
+
delete element.dataset.tabindex;
|
|
223
|
+
if (tabindex) {
|
|
224
|
+
element.setAttribute("tabindex", tabindex);
|
|
225
|
+
} else {
|
|
226
|
+
element.removeAttribute("tabindex");
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
231
|
+
0 && (module.exports = {
|
|
232
|
+
disableFocusInside,
|
|
233
|
+
enableFocusInside,
|
|
234
|
+
focusable,
|
|
235
|
+
getNextTabbable,
|
|
236
|
+
getPreviousTabbable,
|
|
237
|
+
getTabbableAfterElement,
|
|
238
|
+
getTabbableBeforeElement,
|
|
239
|
+
isOutsideEvent,
|
|
240
|
+
isTabbable,
|
|
241
|
+
tabbable
|
|
242
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|