astro-md-editor 0.0.7 → 0.0.8
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/.output/nitro.json +1 -1
- package/.output/public/assets/index-CstiJsWh.js +378 -0
- package/.output/public/assets/{main-BrRIwdKE.js → main-Cc9C-tdG.js} +1 -1
- package/.output/public/assets/styles-DCSwPMSs.css +1 -0
- package/.output/server/{__root-CL_tq3ov.mjs → __root-Bv3dTvZ5.mjs} +1 -1
- package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +210 -0
- package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +11 -0
- package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +69 -0
- package/.output/server/_libs/@radix-ui/react-use-effect-event+[...].mjs +1 -0
- package/.output/server/_libs/@radix-ui/react-use-escape-keydown+[...].mjs +17 -0
- package/.output/server/_libs/@radix-ui/react-use-layout-effect+[...].mjs +6 -0
- package/.output/server/_libs/aria-hidden.mjs +122 -0
- package/.output/server/_libs/base-ui__react.mjs +2548 -2548
- package/.output/server/_libs/base-ui__utils.mjs +2 -2
- package/.output/server/_libs/cmdk.mjs +315 -0
- package/.output/server/_libs/detect-node-es.mjs +1 -0
- package/.output/server/_libs/get-nonce.mjs +9 -0
- package/.output/server/_libs/lucide-react.mjs +25 -17
- package/.output/server/_libs/radix-ui__primitive.mjs +11 -0
- package/.output/server/_libs/radix-ui__react-compose-refs.mjs +39 -0
- package/.output/server/_libs/radix-ui__react-context.mjs +78 -0
- package/.output/server/_libs/radix-ui__react-dialog.mjs +319 -0
- package/.output/server/_libs/radix-ui__react-focus-guards.mjs +29 -0
- package/.output/server/_libs/radix-ui__react-focus-scope.mjs +206 -0
- package/.output/server/_libs/radix-ui__react-id.mjs +14 -0
- package/.output/server/_libs/radix-ui__react-portal.mjs +16 -0
- package/.output/server/_libs/radix-ui__react-presence.mjs +128 -0
- package/.output/server/_libs/radix-ui__react-primitive.mjs +75 -0
- package/.output/server/_libs/radix-ui__react-slot.mjs +184 -0
- package/.output/server/_libs/react-remove-scroll-bar.mjs +82 -0
- package/.output/server/_libs/react-remove-scroll.mjs +328 -0
- package/.output/server/_libs/react-style-singleton.mjs +69 -0
- package/.output/server/_libs/react.mjs +2 -0
- package/.output/server/_libs/tslib.mjs +576 -0
- package/.output/server/_libs/use-callback-ref.mjs +66 -0
- package/.output/server/_libs/use-sidecar.mjs +106 -0
- package/.output/server/_ssr/{ImageAssetBrowser-DNDdTqtf.mjs → ImageAssetBrowser-DuPVChYO.mjs} +2 -2
- package/.output/server/_ssr/{collections.server-s12asITg.mjs → collections.server-DjgohZR7.mjs} +2 -1
- package/.output/server/_ssr/{file-history.api-oydnxFVV.mjs → file-history.api-JMkTXrYq.mjs} +1 -1
- package/.output/server/_ssr/{image-assets.server-Ci2E1_Tm.mjs → image-assets.server-2-0DgxSb.mjs} +1 -1
- package/.output/server/_ssr/{image-preview.api-pcN5PQhH.mjs → image-preview.api-V_Q-MBx9.mjs} +2 -2
- package/.output/server/_ssr/{index-BjQuGIib.mjs → index-ByW88Uz2.mjs} +3 -2
- package/.output/server/_ssr/{index-qpTkRHX1.mjs → index-C6Fb3DjG.mjs} +796 -409
- package/.output/server/_ssr/index.mjs +15 -15
- package/.output/server/_ssr/{router-DU3Hv7p_.mjs → router-DbnWNAi_.mjs} +2 -2
- package/.output/server/{_tanstack-start-manifest_v-BdKE8Xjm.mjs → _tanstack-start-manifest_v-BDWWBEf1.mjs} +1 -1
- package/.output/server/index.mjs +49 -49
- package/LICENSE.md +1 -1
- package/package.json +2 -1
- package/scripts/bootstrap-collections.mjs +2 -0
- package/.output/public/assets/index-CBGDT9fi.js +0 -334
- package/.output/public/assets/styles-CezfLgHY.css +0 -1
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports } from "../react.mjs";
|
|
2
|
+
import { c as composeEventHandlers } from "../radix-ui__primitive.mjs";
|
|
3
|
+
import { a as Primitive, d as dispatchDiscreteCustomEvent } from "../radix-ui__react-primitive.mjs";
|
|
4
|
+
import { u as useComposedRefs } from "../radix-ui__react-compose-refs.mjs";
|
|
5
|
+
import { u as useCallbackRef } from "./react-use-callback-ref+[...].mjs";
|
|
6
|
+
import { u as useEscapeKeydown } from "./react-use-escape-keydown+[...].mjs";
|
|
7
|
+
var DISMISSABLE_LAYER_NAME = "DismissableLayer";
|
|
8
|
+
var CONTEXT_UPDATE = "dismissableLayer.update";
|
|
9
|
+
var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
|
|
10
|
+
var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
|
|
11
|
+
var originalBodyPointerEvents;
|
|
12
|
+
var DismissableLayerContext = reactExports.createContext({
|
|
13
|
+
layers: /* @__PURE__ */ new Set(),
|
|
14
|
+
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
15
|
+
branches: /* @__PURE__ */ new Set()
|
|
16
|
+
});
|
|
17
|
+
var DismissableLayer = reactExports.forwardRef(
|
|
18
|
+
(props, forwardedRef) => {
|
|
19
|
+
const {
|
|
20
|
+
disableOutsidePointerEvents = false,
|
|
21
|
+
onEscapeKeyDown,
|
|
22
|
+
onPointerDownOutside,
|
|
23
|
+
onFocusOutside,
|
|
24
|
+
onInteractOutside,
|
|
25
|
+
onDismiss,
|
|
26
|
+
...layerProps
|
|
27
|
+
} = props;
|
|
28
|
+
const context = reactExports.useContext(DismissableLayerContext);
|
|
29
|
+
const [node, setNode] = reactExports.useState(null);
|
|
30
|
+
const ownerDocument = node?.ownerDocument ?? globalThis?.document;
|
|
31
|
+
const [, force] = reactExports.useState({});
|
|
32
|
+
const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
|
|
33
|
+
const layers = Array.from(context.layers);
|
|
34
|
+
const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
|
|
35
|
+
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
|
|
36
|
+
const index = node ? layers.indexOf(node) : -1;
|
|
37
|
+
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
38
|
+
const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
39
|
+
const pointerDownOutside = usePointerDownOutside((event) => {
|
|
40
|
+
const target = event.target;
|
|
41
|
+
const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
42
|
+
if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
|
|
43
|
+
onPointerDownOutside?.(event);
|
|
44
|
+
onInteractOutside?.(event);
|
|
45
|
+
if (!event.defaultPrevented) onDismiss?.();
|
|
46
|
+
}, ownerDocument);
|
|
47
|
+
const focusOutside = useFocusOutside((event) => {
|
|
48
|
+
const target = event.target;
|
|
49
|
+
const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
50
|
+
if (isFocusInBranch) return;
|
|
51
|
+
onFocusOutside?.(event);
|
|
52
|
+
onInteractOutside?.(event);
|
|
53
|
+
if (!event.defaultPrevented) onDismiss?.();
|
|
54
|
+
}, ownerDocument);
|
|
55
|
+
useEscapeKeydown((event) => {
|
|
56
|
+
const isHighestLayer = index === context.layers.size - 1;
|
|
57
|
+
if (!isHighestLayer) return;
|
|
58
|
+
onEscapeKeyDown?.(event);
|
|
59
|
+
if (!event.defaultPrevented && onDismiss) {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
onDismiss();
|
|
62
|
+
}
|
|
63
|
+
}, ownerDocument);
|
|
64
|
+
reactExports.useEffect(() => {
|
|
65
|
+
if (!node) return;
|
|
66
|
+
if (disableOutsidePointerEvents) {
|
|
67
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
68
|
+
originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
|
|
69
|
+
ownerDocument.body.style.pointerEvents = "none";
|
|
70
|
+
}
|
|
71
|
+
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
72
|
+
}
|
|
73
|
+
context.layers.add(node);
|
|
74
|
+
dispatchUpdate();
|
|
75
|
+
return () => {
|
|
76
|
+
if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
|
|
77
|
+
ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, [node, ownerDocument, disableOutsidePointerEvents, context]);
|
|
81
|
+
reactExports.useEffect(() => {
|
|
82
|
+
return () => {
|
|
83
|
+
if (!node) return;
|
|
84
|
+
context.layers.delete(node);
|
|
85
|
+
context.layersWithOutsidePointerEventsDisabled.delete(node);
|
|
86
|
+
dispatchUpdate();
|
|
87
|
+
};
|
|
88
|
+
}, [node, context]);
|
|
89
|
+
reactExports.useEffect(() => {
|
|
90
|
+
const handleUpdate = () => force({});
|
|
91
|
+
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
92
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
93
|
+
}, []);
|
|
94
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
95
|
+
Primitive.div,
|
|
96
|
+
{
|
|
97
|
+
...layerProps,
|
|
98
|
+
ref: composedRefs,
|
|
99
|
+
style: {
|
|
100
|
+
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
101
|
+
...props.style
|
|
102
|
+
},
|
|
103
|
+
onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
104
|
+
onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
105
|
+
onPointerDownCapture: composeEventHandlers(
|
|
106
|
+
props.onPointerDownCapture,
|
|
107
|
+
pointerDownOutside.onPointerDownCapture
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
|
|
114
|
+
var BRANCH_NAME = "DismissableLayerBranch";
|
|
115
|
+
var DismissableLayerBranch = reactExports.forwardRef((props, forwardedRef) => {
|
|
116
|
+
const context = reactExports.useContext(DismissableLayerContext);
|
|
117
|
+
const ref = reactExports.useRef(null);
|
|
118
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
119
|
+
reactExports.useEffect(() => {
|
|
120
|
+
const node = ref.current;
|
|
121
|
+
if (node) {
|
|
122
|
+
context.branches.add(node);
|
|
123
|
+
return () => {
|
|
124
|
+
context.branches.delete(node);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}, [context.branches]);
|
|
128
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Primitive.div, { ...props, ref: composedRefs });
|
|
129
|
+
});
|
|
130
|
+
DismissableLayerBranch.displayName = BRANCH_NAME;
|
|
131
|
+
function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
|
|
132
|
+
const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
|
|
133
|
+
const isPointerInsideReactTreeRef = reactExports.useRef(false);
|
|
134
|
+
const handleClickRef = reactExports.useRef(() => {
|
|
135
|
+
});
|
|
136
|
+
reactExports.useEffect(() => {
|
|
137
|
+
const handlePointerDown = (event) => {
|
|
138
|
+
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
139
|
+
let handleAndDispatchPointerDownOutsideEvent2 = function() {
|
|
140
|
+
handleAndDispatchCustomEvent(
|
|
141
|
+
POINTER_DOWN_OUTSIDE,
|
|
142
|
+
handlePointerDownOutside,
|
|
143
|
+
eventDetail,
|
|
144
|
+
{ discrete: true }
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
const eventDetail = { originalEvent: event };
|
|
148
|
+
if (event.pointerType === "touch") {
|
|
149
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
150
|
+
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
|
|
151
|
+
ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
|
|
152
|
+
} else {
|
|
153
|
+
handleAndDispatchPointerDownOutsideEvent2();
|
|
154
|
+
}
|
|
155
|
+
} else {
|
|
156
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
157
|
+
}
|
|
158
|
+
isPointerInsideReactTreeRef.current = false;
|
|
159
|
+
};
|
|
160
|
+
const timerId = window.setTimeout(() => {
|
|
161
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown);
|
|
162
|
+
}, 0);
|
|
163
|
+
return () => {
|
|
164
|
+
window.clearTimeout(timerId);
|
|
165
|
+
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
|
|
166
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
167
|
+
};
|
|
168
|
+
}, [ownerDocument, handlePointerDownOutside]);
|
|
169
|
+
return {
|
|
170
|
+
// ensures we check React component tree (not just DOM tree)
|
|
171
|
+
onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
|
|
175
|
+
const handleFocusOutside = useCallbackRef(onFocusOutside);
|
|
176
|
+
const isFocusInsideReactTreeRef = reactExports.useRef(false);
|
|
177
|
+
reactExports.useEffect(() => {
|
|
178
|
+
const handleFocus = (event) => {
|
|
179
|
+
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
180
|
+
const eventDetail = { originalEvent: event };
|
|
181
|
+
handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
|
|
182
|
+
discrete: false
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
ownerDocument.addEventListener("focusin", handleFocus);
|
|
187
|
+
return () => ownerDocument.removeEventListener("focusin", handleFocus);
|
|
188
|
+
}, [ownerDocument, handleFocusOutside]);
|
|
189
|
+
return {
|
|
190
|
+
onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
|
|
191
|
+
onBlurCapture: () => isFocusInsideReactTreeRef.current = false
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function dispatchUpdate() {
|
|
195
|
+
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
196
|
+
document.dispatchEvent(event);
|
|
197
|
+
}
|
|
198
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
199
|
+
const target = detail.originalEvent.target;
|
|
200
|
+
const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
|
|
201
|
+
if (handler) target.addEventListener(name, handler, { once: true });
|
|
202
|
+
if (discrete) {
|
|
203
|
+
dispatchDiscreteCustomEvent(target, event);
|
|
204
|
+
} else {
|
|
205
|
+
target.dispatchEvent(event);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
export {
|
|
209
|
+
DismissableLayer as D
|
|
210
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { r as reactExports } from "../react.mjs";
|
|
2
|
+
function useCallbackRef(callback) {
|
|
3
|
+
const callbackRef = reactExports.useRef(callback);
|
|
4
|
+
reactExports.useEffect(() => {
|
|
5
|
+
callbackRef.current = callback;
|
|
6
|
+
});
|
|
7
|
+
return reactExports.useMemo(() => (...args) => callbackRef.current?.(...args), []);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
useCallbackRef as u
|
|
11
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { r as reactExports, R as React } from "../react.mjs";
|
|
2
|
+
import { u as useLayoutEffect2 } from "./react-use-layout-effect+[...].mjs";
|
|
3
|
+
var useInsertionEffect = React[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
|
|
4
|
+
function useControllableState({
|
|
5
|
+
prop,
|
|
6
|
+
defaultProp,
|
|
7
|
+
onChange = () => {
|
|
8
|
+
},
|
|
9
|
+
caller
|
|
10
|
+
}) {
|
|
11
|
+
const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
|
|
12
|
+
defaultProp,
|
|
13
|
+
onChange
|
|
14
|
+
});
|
|
15
|
+
const isControlled = prop !== void 0;
|
|
16
|
+
const value = isControlled ? prop : uncontrolledProp;
|
|
17
|
+
{
|
|
18
|
+
const isControlledRef = reactExports.useRef(prop !== void 0);
|
|
19
|
+
reactExports.useEffect(() => {
|
|
20
|
+
const wasControlled = isControlledRef.current;
|
|
21
|
+
if (wasControlled !== isControlled) {
|
|
22
|
+
const from = wasControlled ? "controlled" : "uncontrolled";
|
|
23
|
+
const to = isControlled ? "controlled" : "uncontrolled";
|
|
24
|
+
console.warn(
|
|
25
|
+
`${caller} is changing from ${from} to ${to}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
isControlledRef.current = isControlled;
|
|
29
|
+
}, [isControlled, caller]);
|
|
30
|
+
}
|
|
31
|
+
const setValue = reactExports.useCallback(
|
|
32
|
+
(nextValue) => {
|
|
33
|
+
if (isControlled) {
|
|
34
|
+
const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
|
|
35
|
+
if (value2 !== prop) {
|
|
36
|
+
onChangeRef.current?.(value2);
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
setUncontrolledProp(nextValue);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
[isControlled, prop, setUncontrolledProp, onChangeRef]
|
|
43
|
+
);
|
|
44
|
+
return [value, setValue];
|
|
45
|
+
}
|
|
46
|
+
function useUncontrolledState({
|
|
47
|
+
defaultProp,
|
|
48
|
+
onChange
|
|
49
|
+
}) {
|
|
50
|
+
const [value, setValue] = reactExports.useState(defaultProp);
|
|
51
|
+
const prevValueRef = reactExports.useRef(value);
|
|
52
|
+
const onChangeRef = reactExports.useRef(onChange);
|
|
53
|
+
useInsertionEffect(() => {
|
|
54
|
+
onChangeRef.current = onChange;
|
|
55
|
+
}, [onChange]);
|
|
56
|
+
reactExports.useEffect(() => {
|
|
57
|
+
if (prevValueRef.current !== value) {
|
|
58
|
+
onChangeRef.current?.(value);
|
|
59
|
+
prevValueRef.current = value;
|
|
60
|
+
}
|
|
61
|
+
}, [value, prevValueRef]);
|
|
62
|
+
return [value, setValue, onChangeRef];
|
|
63
|
+
}
|
|
64
|
+
function isFunction(value) {
|
|
65
|
+
return typeof value === "function";
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
useControllableState as u
|
|
69
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { r as reactExports } from "../react.mjs";
|
|
2
|
+
import { u as useCallbackRef } from "./react-use-callback-ref+[...].mjs";
|
|
3
|
+
function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
|
|
4
|
+
const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
|
|
5
|
+
reactExports.useEffect(() => {
|
|
6
|
+
const handleKeyDown = (event) => {
|
|
7
|
+
if (event.key === "Escape") {
|
|
8
|
+
onEscapeKeyDown(event);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
12
|
+
return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
13
|
+
}, [onEscapeKeyDown, ownerDocument]);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
useEscapeKeydown as u
|
|
17
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
var getDefaultParent = function(originalTarget) {
|
|
2
|
+
if (typeof document === "undefined") {
|
|
3
|
+
return null;
|
|
4
|
+
}
|
|
5
|
+
var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
|
|
6
|
+
return sampleTarget.ownerDocument.body;
|
|
7
|
+
};
|
|
8
|
+
var counterMap = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
var uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
var markerMap = {};
|
|
11
|
+
var lockCount = 0;
|
|
12
|
+
var unwrapHost = function(node) {
|
|
13
|
+
return node && (node.host || unwrapHost(node.parentNode));
|
|
14
|
+
};
|
|
15
|
+
var correctTargets = function(parent, targets) {
|
|
16
|
+
return targets.map(function(target) {
|
|
17
|
+
if (parent.contains(target)) {
|
|
18
|
+
return target;
|
|
19
|
+
}
|
|
20
|
+
var correctedTarget = unwrapHost(target);
|
|
21
|
+
if (correctedTarget && parent.contains(correctedTarget)) {
|
|
22
|
+
return correctedTarget;
|
|
23
|
+
}
|
|
24
|
+
console.error("aria-hidden", target, "in not contained inside", parent, ". Doing nothing");
|
|
25
|
+
return null;
|
|
26
|
+
}).filter(function(x) {
|
|
27
|
+
return Boolean(x);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var applyAttributeToOthers = function(originalTarget, parentNode, markerName, controlAttribute) {
|
|
31
|
+
var targets = correctTargets(parentNode, Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
32
|
+
if (!markerMap[markerName]) {
|
|
33
|
+
markerMap[markerName] = /* @__PURE__ */ new WeakMap();
|
|
34
|
+
}
|
|
35
|
+
var markerCounter = markerMap[markerName];
|
|
36
|
+
var hiddenNodes = [];
|
|
37
|
+
var elementsToKeep = /* @__PURE__ */ new Set();
|
|
38
|
+
var elementsToStop = new Set(targets);
|
|
39
|
+
var keep = function(el) {
|
|
40
|
+
if (!el || elementsToKeep.has(el)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
elementsToKeep.add(el);
|
|
44
|
+
keep(el.parentNode);
|
|
45
|
+
};
|
|
46
|
+
targets.forEach(keep);
|
|
47
|
+
var deep = function(parent) {
|
|
48
|
+
if (!parent || elementsToStop.has(parent)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
Array.prototype.forEach.call(parent.children, function(node) {
|
|
52
|
+
if (elementsToKeep.has(node)) {
|
|
53
|
+
deep(node);
|
|
54
|
+
} else {
|
|
55
|
+
try {
|
|
56
|
+
var attr = node.getAttribute(controlAttribute);
|
|
57
|
+
var alreadyHidden = attr !== null && attr !== "false";
|
|
58
|
+
var counterValue = (counterMap.get(node) || 0) + 1;
|
|
59
|
+
var markerValue = (markerCounter.get(node) || 0) + 1;
|
|
60
|
+
counterMap.set(node, counterValue);
|
|
61
|
+
markerCounter.set(node, markerValue);
|
|
62
|
+
hiddenNodes.push(node);
|
|
63
|
+
if (counterValue === 1 && alreadyHidden) {
|
|
64
|
+
uncontrolledNodes.set(node, true);
|
|
65
|
+
}
|
|
66
|
+
if (markerValue === 1) {
|
|
67
|
+
node.setAttribute(markerName, "true");
|
|
68
|
+
}
|
|
69
|
+
if (!alreadyHidden) {
|
|
70
|
+
node.setAttribute(controlAttribute, "true");
|
|
71
|
+
}
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.error("aria-hidden: cannot operate on ", node, e);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
deep(parentNode);
|
|
79
|
+
elementsToKeep.clear();
|
|
80
|
+
lockCount++;
|
|
81
|
+
return function() {
|
|
82
|
+
hiddenNodes.forEach(function(node) {
|
|
83
|
+
var counterValue = counterMap.get(node) - 1;
|
|
84
|
+
var markerValue = markerCounter.get(node) - 1;
|
|
85
|
+
counterMap.set(node, counterValue);
|
|
86
|
+
markerCounter.set(node, markerValue);
|
|
87
|
+
if (!counterValue) {
|
|
88
|
+
if (!uncontrolledNodes.has(node)) {
|
|
89
|
+
node.removeAttribute(controlAttribute);
|
|
90
|
+
}
|
|
91
|
+
uncontrolledNodes.delete(node);
|
|
92
|
+
}
|
|
93
|
+
if (!markerValue) {
|
|
94
|
+
node.removeAttribute(markerName);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
lockCount--;
|
|
98
|
+
if (!lockCount) {
|
|
99
|
+
counterMap = /* @__PURE__ */ new WeakMap();
|
|
100
|
+
counterMap = /* @__PURE__ */ new WeakMap();
|
|
101
|
+
uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
102
|
+
markerMap = {};
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
var hideOthers = function(originalTarget, parentNode, markerName) {
|
|
107
|
+
if (markerName === void 0) {
|
|
108
|
+
markerName = "data-aria-hidden";
|
|
109
|
+
}
|
|
110
|
+
var targets = Array.from(Array.isArray(originalTarget) ? originalTarget : [originalTarget]);
|
|
111
|
+
var activeParentNode = getDefaultParent(originalTarget);
|
|
112
|
+
if (!activeParentNode) {
|
|
113
|
+
return function() {
|
|
114
|
+
return null;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
targets.push.apply(targets, Array.from(activeParentNode.querySelectorAll("[aria-live], script")));
|
|
118
|
+
return applyAttributeToOthers(targets, activeParentNode, markerName, "aria-hidden");
|
|
119
|
+
};
|
|
120
|
+
export {
|
|
121
|
+
hideOthers as h
|
|
122
|
+
};
|