@adam-milo/ui 1.0.29 → 1.0.31
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/index.cjs +1 -1
- package/dist/index.js +3 -1
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +1 -1
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +1 -1
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +1 -1
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +1 -1
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +2 -2
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +1 -1
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +1 -1
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +1 -1
- package/dist/index2.cjs +1 -1
- package/dist/index2.js +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +53 -12
- package/dist/index21.cjs +1 -0
- package/dist/index21.js +14 -0
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +20 -299
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +298 -13
- package/dist/index25.cjs +1 -0
- package/dist/index25.js +16 -0
- package/dist/{index27.cjs → index28.cjs} +1 -1
- package/dist/{index27.js → index28.js} +21 -21
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +2 -2
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +1 -1
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +16 -6
- package/dist/index44.cjs +1 -1
- package/dist/index44.js +3 -36
- package/dist/index45.cjs +1 -1
- package/dist/index45.js +6 -59
- package/dist/index46.cjs +1 -1
- package/dist/index46.js +67 -7
- package/dist/index47.cjs +1 -1
- package/dist/index47.js +28 -201
- package/dist/index48.cjs +1 -1
- package/dist/index48.js +58 -23
- package/dist/index49.cjs +1 -1
- package/dist/index49.js +6 -204
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +1 -1
- package/dist/index50.cjs +1 -1
- package/dist/index50.js +208 -10
- package/dist/index51.cjs +1 -1
- package/dist/index51.js +22 -286
- package/dist/index52.cjs +1 -1
- package/dist/index52.js +203 -13
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +10 -39
- package/dist/index54.cjs +1 -1
- package/dist/index54.js +283 -79
- package/dist/index55.cjs +1 -1
- package/dist/index55.js +15 -11
- package/dist/index56.cjs +1 -1
- package/dist/index56.js +38 -66
- package/dist/index57.cjs +1 -1
- package/dist/index57.js +86 -3
- package/dist/index58.cjs +1 -1
- package/dist/index58.js +10 -10
- package/dist/index59.cjs +1 -1
- package/dist/index59.js +66 -29
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +2 -2
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +3 -119
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +11 -8
- package/dist/index62.cjs +1 -0
- package/dist/index62.js +34 -0
- package/dist/index63.cjs +1 -1
- package/dist/index63.js +118 -13
- package/dist/index64.cjs +1 -1
- package/dist/index64.js +7 -293
- package/dist/index65.cjs +1 -1
- package/dist/index65.js +14 -22
- package/dist/index66.cjs +1 -1
- package/dist/index66.js +291 -33
- package/dist/index67.cjs +1 -1
- package/dist/index67.js +22 -622
- package/dist/index68.cjs +1 -1
- package/dist/index68.js +35 -35
- package/dist/index69.cjs +1 -1
- package/dist/index69.js +620 -33
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +1 -1
- package/dist/index70.cjs +1 -1
- package/dist/index70.js +37 -5
- package/dist/index71.cjs +1 -1
- package/dist/index71.js +36 -8
- package/dist/index72.cjs +1 -1
- package/dist/index72.js +5 -3
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +8 -33
- package/dist/index74.cjs +1 -1
- package/dist/index74.js +3 -178
- package/dist/index75.cjs +1 -1
- package/dist/index75.js +31 -17
- package/dist/index76.cjs +1 -1
- package/dist/index76.js +165 -706
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +16 -149
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +697 -149
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +146 -80
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +1 -1
- package/dist/index80.cjs +1 -1
- package/dist/index80.js +170 -44
- package/dist/index81.cjs +1 -1
- package/dist/index81.js +44 -10
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +11 -17
- package/dist/index83.cjs +1 -1
- package/dist/index83.js +14 -97
- package/dist/index84.cjs +1 -1
- package/dist/index84.js +99 -8
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +82 -23
- package/dist/index86.cjs +1 -1
- package/dist/index86.js +8 -34
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +27 -14
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +30 -41
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +13 -6
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +2 -2
- package/dist/index90.cjs +1 -0
- package/dist/index90.js +48 -0
- package/dist/index91.cjs +1 -0
- package/dist/index91.js +9 -0
- package/dist/src/components/forms/radio/Radio.component.d.ts.map +1 -1
- package/dist/src/components/layout/grid/Grid.component.d.ts +53 -0
- package/dist/src/components/layout/grid/Grid.component.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/dist/index22.cjs +0 -1
- package/dist/index22.js +0 -22
- package/dist/index40.cjs +0 -1
- package/dist/index40.js +0 -21
- package/dist/index41.cjs +0 -1
- package/dist/index41.js +0 -6
- package/dist/index43.cjs +0 -1
- package/dist/index43.js +0 -70
- /package/dist/{index35.cjs → index36.cjs} +0 -0
- /package/dist/{index35.js → index36.js} +0 -0
package/dist/index50.js
CHANGED
|
@@ -1,14 +1,212 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { composeEventHandlers } from "./index45.js";
|
|
3
|
+
import { Primitive, dispatchDiscreteCustomEvent } from "./index56.js";
|
|
4
|
+
import { useComposedRefs } from "./index47.js";
|
|
5
|
+
import { useCallbackRef } from "./index58.js";
|
|
6
|
+
import { useEscapeKeydown } from "./index65.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var DISMISSABLE_LAYER_NAME = "DismissableLayer";
|
|
9
|
+
var CONTEXT_UPDATE = "dismissableLayer.update";
|
|
10
|
+
var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
|
|
11
|
+
var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
|
|
12
|
+
var originalBodyPointerEvents;
|
|
13
|
+
var DismissableLayerContext = React.createContext({
|
|
14
|
+
layers: /* @__PURE__ */ new Set(),
|
|
15
|
+
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
16
|
+
branches: /* @__PURE__ */ new Set()
|
|
17
|
+
});
|
|
18
|
+
var DismissableLayer = React.forwardRef(
|
|
19
|
+
(props, forwardedRef) => {
|
|
20
|
+
const {
|
|
21
|
+
disableOutsidePointerEvents = false,
|
|
22
|
+
onEscapeKeyDown,
|
|
23
|
+
onPointerDownOutside,
|
|
24
|
+
onFocusOutside,
|
|
25
|
+
onInteractOutside,
|
|
26
|
+
onDismiss,
|
|
27
|
+
...layerProps
|
|
28
|
+
} = props;
|
|
29
|
+
const context = React.useContext(DismissableLayerContext);
|
|
30
|
+
const [node, setNode] = React.useState(null);
|
|
31
|
+
const ownerDocument = (node == null ? void 0 : node.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document);
|
|
32
|
+
const [, force] = React.useState({});
|
|
33
|
+
const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
|
|
34
|
+
const layers = Array.from(context.layers);
|
|
35
|
+
const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
|
|
36
|
+
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
|
|
37
|
+
const index = node ? layers.indexOf(node) : -1;
|
|
38
|
+
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
39
|
+
const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
40
|
+
const pointerDownOutside = usePointerDownOutside((event) => {
|
|
41
|
+
const target = event.target;
|
|
42
|
+
const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
43
|
+
if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
|
|
44
|
+
onPointerDownOutside == null ? void 0 : onPointerDownOutside(event);
|
|
45
|
+
onInteractOutside == null ? void 0 : onInteractOutside(event);
|
|
46
|
+
if (!event.defaultPrevented) onDismiss == null ? void 0 : onDismiss();
|
|
47
|
+
}, ownerDocument);
|
|
48
|
+
const focusOutside = useFocusOutside((event) => {
|
|
49
|
+
const target = event.target;
|
|
50
|
+
const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
51
|
+
if (isFocusInBranch) return;
|
|
52
|
+
onFocusOutside == null ? void 0 : onFocusOutside(event);
|
|
53
|
+
onInteractOutside == null ? void 0 : onInteractOutside(event);
|
|
54
|
+
if (!event.defaultPrevented) onDismiss == null ? void 0 : onDismiss();
|
|
55
|
+
}, ownerDocument);
|
|
56
|
+
useEscapeKeydown((event) => {
|
|
57
|
+
const isHighestLayer = index === context.layers.size - 1;
|
|
58
|
+
if (!isHighestLayer) return;
|
|
59
|
+
onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event);
|
|
60
|
+
if (!event.defaultPrevented && onDismiss) {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
onDismiss();
|
|
63
|
+
}
|
|
64
|
+
}, ownerDocument);
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
if (!node) return;
|
|
67
|
+
if (disableOutsidePointerEvents) {
|
|
68
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
69
|
+
originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
|
|
70
|
+
ownerDocument.body.style.pointerEvents = "none";
|
|
71
|
+
}
|
|
72
|
+
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
73
|
+
}
|
|
74
|
+
context.layers.add(node);
|
|
75
|
+
dispatchUpdate();
|
|
76
|
+
return () => {
|
|
77
|
+
if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
|
|
78
|
+
ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}, [node, ownerDocument, disableOutsidePointerEvents, context]);
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
return () => {
|
|
84
|
+
if (!node) return;
|
|
85
|
+
context.layers.delete(node);
|
|
86
|
+
context.layersWithOutsidePointerEventsDisabled.delete(node);
|
|
87
|
+
dispatchUpdate();
|
|
88
|
+
};
|
|
89
|
+
}, [node, context]);
|
|
90
|
+
React.useEffect(() => {
|
|
91
|
+
const handleUpdate = () => force({});
|
|
92
|
+
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
93
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
94
|
+
}, []);
|
|
95
|
+
return /* @__PURE__ */ jsx(
|
|
96
|
+
Primitive.div,
|
|
97
|
+
{
|
|
98
|
+
...layerProps,
|
|
99
|
+
ref: composedRefs,
|
|
100
|
+
style: {
|
|
101
|
+
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
102
|
+
...props.style
|
|
103
|
+
},
|
|
104
|
+
onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
105
|
+
onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
106
|
+
onPointerDownCapture: composeEventHandlers(
|
|
107
|
+
props.onPointerDownCapture,
|
|
108
|
+
pointerDownOutside.onPointerDownCapture
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
|
|
115
|
+
var BRANCH_NAME = "DismissableLayerBranch";
|
|
116
|
+
var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
|
|
117
|
+
const context = React.useContext(DismissableLayerContext);
|
|
118
|
+
const ref = React.useRef(null);
|
|
119
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
120
|
+
React.useEffect(() => {
|
|
121
|
+
const node = ref.current;
|
|
122
|
+
if (node) {
|
|
123
|
+
context.branches.add(node);
|
|
124
|
+
return () => {
|
|
125
|
+
context.branches.delete(node);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}, [context.branches]);
|
|
129
|
+
return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
|
|
130
|
+
});
|
|
131
|
+
DismissableLayerBranch.displayName = BRANCH_NAME;
|
|
132
|
+
function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
|
|
133
|
+
const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
|
|
134
|
+
const isPointerInsideReactTreeRef = React.useRef(false);
|
|
135
|
+
const handleClickRef = React.useRef(() => {
|
|
136
|
+
});
|
|
137
|
+
React.useEffect(() => {
|
|
138
|
+
const handlePointerDown = (event) => {
|
|
139
|
+
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
140
|
+
let handleAndDispatchPointerDownOutsideEvent2 = function() {
|
|
141
|
+
handleAndDispatchCustomEvent(
|
|
142
|
+
POINTER_DOWN_OUTSIDE,
|
|
143
|
+
handlePointerDownOutside,
|
|
144
|
+
eventDetail,
|
|
145
|
+
{ discrete: true }
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
const eventDetail = { originalEvent: event };
|
|
149
|
+
if (event.pointerType === "touch") {
|
|
150
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
151
|
+
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
|
|
152
|
+
ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
|
|
153
|
+
} else {
|
|
154
|
+
handleAndDispatchPointerDownOutsideEvent2();
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
158
|
+
}
|
|
159
|
+
isPointerInsideReactTreeRef.current = false;
|
|
160
|
+
};
|
|
161
|
+
const timerId = window.setTimeout(() => {
|
|
162
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown);
|
|
163
|
+
}, 0);
|
|
164
|
+
return () => {
|
|
165
|
+
window.clearTimeout(timerId);
|
|
166
|
+
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
|
|
167
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
168
|
+
};
|
|
169
|
+
}, [ownerDocument, handlePointerDownOutside]);
|
|
170
|
+
return {
|
|
171
|
+
// ensures we check React component tree (not just DOM tree)
|
|
172
|
+
onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function useFocusOutside(onFocusOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
|
|
176
|
+
const handleFocusOutside = useCallbackRef(onFocusOutside);
|
|
177
|
+
const isFocusInsideReactTreeRef = React.useRef(false);
|
|
178
|
+
React.useEffect(() => {
|
|
179
|
+
const handleFocus = (event) => {
|
|
180
|
+
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
181
|
+
const eventDetail = { originalEvent: event };
|
|
182
|
+
handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
|
|
183
|
+
discrete: false
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
ownerDocument.addEventListener("focusin", handleFocus);
|
|
188
|
+
return () => ownerDocument.removeEventListener("focusin", handleFocus);
|
|
189
|
+
}, [ownerDocument, handleFocusOutside]);
|
|
190
|
+
return {
|
|
191
|
+
onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
|
|
192
|
+
onBlurCapture: () => isFocusInsideReactTreeRef.current = false
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function dispatchUpdate() {
|
|
196
|
+
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
197
|
+
document.dispatchEvent(event);
|
|
198
|
+
}
|
|
199
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
200
|
+
const target = detail.originalEvent.target;
|
|
201
|
+
const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
|
|
202
|
+
if (handler) target.addEventListener(name, handler, { once: true });
|
|
203
|
+
if (discrete) {
|
|
204
|
+
dispatchDiscreteCustomEvent(target, event);
|
|
205
|
+
} else {
|
|
206
|
+
target.dispatchEvent(event);
|
|
207
|
+
}
|
|
11
208
|
}
|
|
12
209
|
export {
|
|
13
|
-
|
|
210
|
+
DismissableLayer,
|
|
211
|
+
DismissableLayerBranch
|
|
14
212
|
};
|
package/dist/index51.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const t=e(require("react"));var n=0;function r(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}exports.useFocusGuards=function(){t.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??r()),document.body.insertAdjacentElement("beforeend",e[1]??r()),n++,()=>{1===n&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),n--}},[])};
|
package/dist/index51.js
CHANGED
|
@@ -1,293 +1,29 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var POPPER_NAME = "Popper";
|
|
13
|
-
var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
|
|
14
|
-
var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
|
|
15
|
-
var Popper = (props) => {
|
|
16
|
-
const { __scopePopper, children } = props;
|
|
17
|
-
const [anchor, setAnchor] = React.useState(null);
|
|
18
|
-
return /* @__PURE__ */ jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
|
|
19
|
-
};
|
|
20
|
-
Popper.displayName = POPPER_NAME;
|
|
21
|
-
var ANCHOR_NAME = "PopperAnchor";
|
|
22
|
-
var PopperAnchor = React.forwardRef(
|
|
23
|
-
(props, forwardedRef) => {
|
|
24
|
-
const { __scopePopper, virtualRef, ...anchorProps } = props;
|
|
25
|
-
const context = usePopperContext(ANCHOR_NAME, __scopePopper);
|
|
26
|
-
const ref = React.useRef(null);
|
|
27
|
-
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
28
|
-
const anchorRef = React.useRef(null);
|
|
29
|
-
React.useEffect(() => {
|
|
30
|
-
const previousAnchor = anchorRef.current;
|
|
31
|
-
anchorRef.current = (virtualRef == null ? void 0 : virtualRef.current) || ref.current;
|
|
32
|
-
if (previousAnchor !== anchorRef.current) {
|
|
33
|
-
context.onAnchorChange(anchorRef.current);
|
|
2
|
+
var count = 0;
|
|
3
|
+
function useFocusGuards() {
|
|
4
|
+
React.useEffect(() => {
|
|
5
|
+
const edgeGuards = document.querySelectorAll("[data-radix-focus-guard]");
|
|
6
|
+
document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? createFocusGuard());
|
|
7
|
+
document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? createFocusGuard());
|
|
8
|
+
count++;
|
|
9
|
+
return () => {
|
|
10
|
+
if (count === 1) {
|
|
11
|
+
document.querySelectorAll("[data-radix-focus-guard]").forEach((node) => node.remove());
|
|
34
12
|
}
|
|
35
|
-
|
|
36
|
-
return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
PopperAnchor.displayName = ANCHOR_NAME;
|
|
40
|
-
var CONTENT_NAME = "PopperContent";
|
|
41
|
-
var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME);
|
|
42
|
-
var PopperContent = React.forwardRef(
|
|
43
|
-
(props, forwardedRef) => {
|
|
44
|
-
var _a, _b, _c, _d, _e, _f;
|
|
45
|
-
const {
|
|
46
|
-
__scopePopper,
|
|
47
|
-
side = "bottom",
|
|
48
|
-
sideOffset = 0,
|
|
49
|
-
align = "center",
|
|
50
|
-
alignOffset = 0,
|
|
51
|
-
arrowPadding = 0,
|
|
52
|
-
avoidCollisions = true,
|
|
53
|
-
collisionBoundary = [],
|
|
54
|
-
collisionPadding: collisionPaddingProp = 0,
|
|
55
|
-
sticky = "partial",
|
|
56
|
-
hideWhenDetached = false,
|
|
57
|
-
updatePositionStrategy = "optimized",
|
|
58
|
-
onPlaced,
|
|
59
|
-
...contentProps
|
|
60
|
-
} = props;
|
|
61
|
-
const context = usePopperContext(CONTENT_NAME, __scopePopper);
|
|
62
|
-
const [content, setContent] = React.useState(null);
|
|
63
|
-
const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
|
|
64
|
-
const [arrow$1, setArrow] = React.useState(null);
|
|
65
|
-
const arrowSize = useSize(arrow$1);
|
|
66
|
-
const arrowWidth = (arrowSize == null ? void 0 : arrowSize.width) ?? 0;
|
|
67
|
-
const arrowHeight = (arrowSize == null ? void 0 : arrowSize.height) ?? 0;
|
|
68
|
-
const desiredPlacement = side + (align !== "center" ? "-" + align : "");
|
|
69
|
-
const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
|
|
70
|
-
const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
|
|
71
|
-
const hasExplicitBoundaries = boundary.length > 0;
|
|
72
|
-
const detectOverflowOptions = {
|
|
73
|
-
padding: collisionPadding,
|
|
74
|
-
boundary: boundary.filter(isNotNull),
|
|
75
|
-
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
|
76
|
-
altBoundary: hasExplicitBoundaries
|
|
13
|
+
count--;
|
|
77
14
|
};
|
|
78
|
-
|
|
79
|
-
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
|
|
80
|
-
strategy: "fixed",
|
|
81
|
-
placement: desiredPlacement,
|
|
82
|
-
whileElementsMounted: (...args) => {
|
|
83
|
-
const cleanup = autoUpdate(...args, {
|
|
84
|
-
animationFrame: updatePositionStrategy === "always"
|
|
85
|
-
});
|
|
86
|
-
return cleanup;
|
|
87
|
-
},
|
|
88
|
-
elements: {
|
|
89
|
-
reference: context.anchor
|
|
90
|
-
},
|
|
91
|
-
middleware: [
|
|
92
|
-
offset({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }),
|
|
93
|
-
avoidCollisions && shift({
|
|
94
|
-
mainAxis: true,
|
|
95
|
-
crossAxis: false,
|
|
96
|
-
limiter: sticky === "partial" ? limitShift() : void 0,
|
|
97
|
-
...detectOverflowOptions
|
|
98
|
-
}),
|
|
99
|
-
avoidCollisions && flip({ ...detectOverflowOptions }),
|
|
100
|
-
size({
|
|
101
|
-
...detectOverflowOptions,
|
|
102
|
-
apply: ({ elements, rects, availableWidth, availableHeight }) => {
|
|
103
|
-
const { width: anchorWidth, height: anchorHeight } = rects.reference;
|
|
104
|
-
const contentStyle = elements.floating.style;
|
|
105
|
-
contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
|
|
106
|
-
contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
|
|
107
|
-
contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
|
|
108
|
-
contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
|
|
109
|
-
}
|
|
110
|
-
}),
|
|
111
|
-
arrow$1 && arrow({ element: arrow$1, padding: arrowPadding }),
|
|
112
|
-
transformOrigin({ arrowWidth, arrowHeight }),
|
|
113
|
-
hideWhenDetached && hide({ strategy: "referenceHidden", ...detectOverflowOptions })
|
|
114
|
-
]
|
|
115
|
-
});
|
|
116
|
-
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
117
|
-
const handlePlaced = useCallbackRef(onPlaced);
|
|
118
|
-
useLayoutEffect2(() => {
|
|
119
|
-
if (isPositioned) {
|
|
120
|
-
handlePlaced == null ? void 0 : handlePlaced();
|
|
121
|
-
}
|
|
122
|
-
}, [isPositioned, handlePlaced]);
|
|
123
|
-
const arrowX = (_a = middlewareData.arrow) == null ? void 0 : _a.x;
|
|
124
|
-
const arrowY = (_b = middlewareData.arrow) == null ? void 0 : _b.y;
|
|
125
|
-
const cannotCenterArrow = ((_c = middlewareData.arrow) == null ? void 0 : _c.centerOffset) !== 0;
|
|
126
|
-
const [contentZIndex, setContentZIndex] = React.useState();
|
|
127
|
-
useLayoutEffect2(() => {
|
|
128
|
-
if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
|
|
129
|
-
}, [content]);
|
|
130
|
-
return /* @__PURE__ */ jsx(
|
|
131
|
-
"div",
|
|
132
|
-
{
|
|
133
|
-
ref: refs.setFloating,
|
|
134
|
-
"data-radix-popper-content-wrapper": "",
|
|
135
|
-
style: {
|
|
136
|
-
...floatingStyles,
|
|
137
|
-
transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
|
|
138
|
-
// keep off the page when measuring
|
|
139
|
-
minWidth: "max-content",
|
|
140
|
-
zIndex: contentZIndex,
|
|
141
|
-
["--radix-popper-transform-origin"]: [
|
|
142
|
-
(_d = middlewareData.transformOrigin) == null ? void 0 : _d.x,
|
|
143
|
-
(_e = middlewareData.transformOrigin) == null ? void 0 : _e.y
|
|
144
|
-
].join(" "),
|
|
145
|
-
// hide the content if using the hide middleware and should be hidden
|
|
146
|
-
// set visibility to hidden and disable pointer events so the UI behaves
|
|
147
|
-
// as if the PopperContent isn't there at all
|
|
148
|
-
...((_f = middlewareData.hide) == null ? void 0 : _f.referenceHidden) && {
|
|
149
|
-
visibility: "hidden",
|
|
150
|
-
pointerEvents: "none"
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
dir: props.dir,
|
|
154
|
-
children: /* @__PURE__ */ jsx(
|
|
155
|
-
PopperContentProvider,
|
|
156
|
-
{
|
|
157
|
-
scope: __scopePopper,
|
|
158
|
-
placedSide,
|
|
159
|
-
onArrowChange: setArrow,
|
|
160
|
-
arrowX,
|
|
161
|
-
arrowY,
|
|
162
|
-
shouldHideArrow: cannotCenterArrow,
|
|
163
|
-
children: /* @__PURE__ */ jsx(
|
|
164
|
-
Primitive.div,
|
|
165
|
-
{
|
|
166
|
-
"data-side": placedSide,
|
|
167
|
-
"data-align": placedAlign,
|
|
168
|
-
...contentProps,
|
|
169
|
-
ref: composedRefs,
|
|
170
|
-
style: {
|
|
171
|
-
...contentProps.style,
|
|
172
|
-
// if the PopperContent hasn't been placed yet (not all measurements done)
|
|
173
|
-
// we prevent animations so that users's animation don't kick in too early referring wrong sides
|
|
174
|
-
animation: !isPositioned ? "none" : void 0
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
)
|
|
180
|
-
}
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
);
|
|
184
|
-
PopperContent.displayName = CONTENT_NAME;
|
|
185
|
-
var ARROW_NAME = "PopperArrow";
|
|
186
|
-
var OPPOSITE_SIDE = {
|
|
187
|
-
top: "bottom",
|
|
188
|
-
right: "left",
|
|
189
|
-
bottom: "top",
|
|
190
|
-
left: "right"
|
|
191
|
-
};
|
|
192
|
-
var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
|
|
193
|
-
const { __scopePopper, ...arrowProps } = props;
|
|
194
|
-
const contentContext = useContentContext(ARROW_NAME, __scopePopper);
|
|
195
|
-
const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
|
|
196
|
-
return (
|
|
197
|
-
// we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
|
|
198
|
-
// doesn't report size as we'd expect on SVG elements.
|
|
199
|
-
// it reports their bounding box which is effectively the largest path inside the SVG.
|
|
200
|
-
/* @__PURE__ */ jsx(
|
|
201
|
-
"span",
|
|
202
|
-
{
|
|
203
|
-
ref: contentContext.onArrowChange,
|
|
204
|
-
style: {
|
|
205
|
-
position: "absolute",
|
|
206
|
-
left: contentContext.arrowX,
|
|
207
|
-
top: contentContext.arrowY,
|
|
208
|
-
[baseSide]: 0,
|
|
209
|
-
transformOrigin: {
|
|
210
|
-
top: "",
|
|
211
|
-
right: "0 0",
|
|
212
|
-
bottom: "center 0",
|
|
213
|
-
left: "100% 0"
|
|
214
|
-
}[contentContext.placedSide],
|
|
215
|
-
transform: {
|
|
216
|
-
top: "translateY(100%)",
|
|
217
|
-
right: "translateY(50%) rotate(90deg) translateX(-50%)",
|
|
218
|
-
bottom: `rotate(180deg)`,
|
|
219
|
-
left: "translateY(50%) rotate(-90deg) translateX(50%)"
|
|
220
|
-
}[contentContext.placedSide],
|
|
221
|
-
visibility: contentContext.shouldHideArrow ? "hidden" : void 0
|
|
222
|
-
},
|
|
223
|
-
children: /* @__PURE__ */ jsx(
|
|
224
|
-
Root,
|
|
225
|
-
{
|
|
226
|
-
...arrowProps,
|
|
227
|
-
ref: forwardedRef,
|
|
228
|
-
style: {
|
|
229
|
-
...arrowProps.style,
|
|
230
|
-
// ensures the element can be measured correctly (mostly for if SVG)
|
|
231
|
-
display: "block"
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
)
|
|
235
|
-
}
|
|
236
|
-
)
|
|
237
|
-
);
|
|
238
|
-
});
|
|
239
|
-
PopperArrow.displayName = ARROW_NAME;
|
|
240
|
-
function isNotNull(value) {
|
|
241
|
-
return value !== null;
|
|
15
|
+
}, []);
|
|
242
16
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
|
|
253
|
-
const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
|
|
254
|
-
const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
|
|
255
|
-
const arrowXCenter = (((_b = middlewareData.arrow) == null ? void 0 : _b.x) ?? 0) + arrowWidth / 2;
|
|
256
|
-
const arrowYCenter = (((_c = middlewareData.arrow) == null ? void 0 : _c.y) ?? 0) + arrowHeight / 2;
|
|
257
|
-
let x = "";
|
|
258
|
-
let y = "";
|
|
259
|
-
if (placedSide === "bottom") {
|
|
260
|
-
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
|
261
|
-
y = `${-arrowHeight}px`;
|
|
262
|
-
} else if (placedSide === "top") {
|
|
263
|
-
x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
|
|
264
|
-
y = `${rects.floating.height + arrowHeight}px`;
|
|
265
|
-
} else if (placedSide === "right") {
|
|
266
|
-
x = `${-arrowHeight}px`;
|
|
267
|
-
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
|
268
|
-
} else if (placedSide === "left") {
|
|
269
|
-
x = `${rects.floating.width + arrowHeight}px`;
|
|
270
|
-
y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
|
|
271
|
-
}
|
|
272
|
-
return { data: { x, y } };
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
function getSideAndAlignFromPlacement(placement) {
|
|
276
|
-
const [side, align = "center"] = placement.split("-");
|
|
277
|
-
return [side, align];
|
|
17
|
+
function createFocusGuard() {
|
|
18
|
+
const element = document.createElement("span");
|
|
19
|
+
element.setAttribute("data-radix-focus-guard", "");
|
|
20
|
+
element.tabIndex = 0;
|
|
21
|
+
element.style.outline = "none";
|
|
22
|
+
element.style.opacity = "0";
|
|
23
|
+
element.style.position = "fixed";
|
|
24
|
+
element.style.pointerEvents = "none";
|
|
25
|
+
return element;
|
|
278
26
|
}
|
|
279
|
-
var Root2 = Popper;
|
|
280
|
-
var Anchor = PopperAnchor;
|
|
281
|
-
var Content = PopperContent;
|
|
282
|
-
var Arrow = PopperArrow;
|
|
283
27
|
export {
|
|
284
|
-
|
|
285
|
-
Arrow,
|
|
286
|
-
Content,
|
|
287
|
-
Popper,
|
|
288
|
-
PopperAnchor,
|
|
289
|
-
PopperArrow,
|
|
290
|
-
PopperContent,
|
|
291
|
-
Root2 as Root,
|
|
292
|
-
createPopperScope
|
|
28
|
+
useFocusGuards
|
|
293
29
|
};
|
package/dist/index52.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("./index47.cjs"),n=require("./index56.cjs"),o=require("./index58.cjs"),r=require("react/jsx-runtime");function u(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const c=u(e);var s="focusScope.autoFocusOnMount",i="focusScope.autoFocusOnUnmount",a={bubbles:!1,cancelable:!0},d=c.forwardRef((e,u)=>{const{loop:d=!1,trapped:m=!1,onMountAutoFocus:E,onUnmountAutoFocus:b,...y}=e,[T,g]=c.useState(null),S=o.useCallbackRef(E),L=o.useCallbackRef(b),h=c.useRef(null),F=t.useComposedRefs(u,e=>g(e)),N=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(m){let e=function(e){if(N.paused||!T)return;const t=e.target;T.contains(t)?h.current=t:v(h.current,{select:!0})},t=function(e){if(N.paused||!T)return;const t=e.relatedTarget;null!==t&&(T.contains(t)||v(h.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&v(T)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const o=new MutationObserver(n);return T&&o.observe(T,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),o.disconnect()}}},[m,T,N.paused]),c.useEffect(()=>{if(T){p.add(N);const t=document.activeElement;if(!T.contains(t)){const n=new CustomEvent(s,a);T.addEventListener(s,S),T.dispatchEvent(n),n.defaultPrevented||(!function(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(v(o,{select:t}),document.activeElement!==n)return}((e=l(T),e.filter(e=>"A"!==e.tagName)),{select:!0}),document.activeElement===t&&v(T))}return()=>{T.removeEventListener(s,S),setTimeout(()=>{const e=new CustomEvent(i,a);T.addEventListener(i,L),T.dispatchEvent(e),e.defaultPrevented||v(t??document.body,{select:!0}),T.removeEventListener(i,L),p.remove(N)},0)}}var e},[T,S,L,N]);const x=c.useCallback(e=>{if(!d&&!m)return;if(N.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){const t=e.currentTarget,[o,r]=function(e){const t=l(e),n=f(t,e),o=f(t.reverse(),e);return[n,o]}(t);o&&r?e.shiftKey||n!==r?e.shiftKey&&n===o&&(e.preventDefault(),d&&v(r,{select:!0})):(e.preventDefault(),d&&v(o,{select:!0})):n===t&&e.preventDefault()}},[d,m,N.paused]);return r.jsx(n.Primitive.div,{tabIndex:-1,...y,ref:F,onKeyDown:x})});function l(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function f(e,t){for(const n of e)if(!m(n,{upTo:t}))return n}function m(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function v(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}d.displayName="FocusScope";var p=function(){let e=[];return{add(t){const n=e[0];t!==n&&(null==n||n.pause()),e=E(e,t),e.unshift(t)},remove(t){var n;e=E(e,t),null==(n=e[0])||n.resume()}}}();function E(e,t){const n=[...e],o=n.indexOf(t);return-1!==o&&n.splice(o,1),n}exports.FocusScope=d;
|