xmlui 0.9.82 → 0.9.83

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xmlui",
3
- "version": "0.9.82",
3
+ "version": "0.9.83",
4
4
  "sideEffects": false,
5
5
  "scripts": {
6
6
  "start-test-bed": "cd src/testing/infrastructure && xmlui start",
@@ -35,6 +35,11 @@ exports.BookmarkMd = (0, metadata_helpers_1.createMetadata)({
35
35
  defaultValue: BookmarkNative_1.defaultProps.omitFromToc,
36
36
  },
37
37
  },
38
+ apis: {
39
+ scrollIntoView: {
40
+ description: "Scrolls the bookmark into view.",
41
+ },
42
+ },
38
43
  });
39
44
  exports.bookmarkComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.BookmarkMd, (rendererContext) => {
40
45
  const { node, renderChild, extractValue, layoutContext } = rendererContext;
@@ -12,11 +12,21 @@ exports.defaultProps = {
12
12
  level: 1,
13
13
  omitFromToc: false,
14
14
  };
15
- const Bookmark = ({ uid, level = exports.defaultProps.level, children, title, omitFromToc = exports.defaultProps.omitFromToc, }) => {
15
+ const Bookmark = ({ uid, level = exports.defaultProps.level, children, title, omitFromToc = exports.defaultProps.omitFromToc, registerComponentApi, }) => {
16
16
  const elementRef = (0, react_1.useRef)(null);
17
17
  const tableOfContentsContext = (0, react_1.useContext)(TableOfContentsContext_1.TableOfContentsContext);
18
18
  const registerHeading = tableOfContentsContext === null || tableOfContentsContext === void 0 ? void 0 : tableOfContentsContext.registerHeading;
19
19
  const observeIntersection = tableOfContentsContext === null || tableOfContentsContext === void 0 ? void 0 : tableOfContentsContext.hasTableOfContents;
20
+ const scrollIntoView = (0, react_1.useCallback)((options) => {
21
+ if (elementRef.current) {
22
+ elementRef.current.scrollIntoView(Object.assign({ behavior: 'smooth', block: 'start' }, options));
23
+ }
24
+ }, []);
25
+ (0, react_1.useEffect)(() => {
26
+ registerComponentApi === null || registerComponentApi === void 0 ? void 0 : registerComponentApi({
27
+ scrollIntoView,
28
+ });
29
+ }, [registerComponentApi, scrollIntoView]);
20
30
  (0, react_1.useLayoutEffect)(() => {
21
31
  var _a, _b, _c;
22
32
  if (observeIntersection && elementRef.current && uid && !omitFromToc) {
@@ -121,7 +121,9 @@ exports.ModalDialog = react_1.default.forwardRef(({ children, style, isInitially
121
121
  // NOTE: at this point, we can't use useAppContext here,
122
122
  // since the ModalDialog context provider (via ConfirmationModalContextProvider) is mounted outside of the AppContext,
123
123
  // and ModalDialogs can also be called using the imperative API (see functions like "confirm")
124
- const isDialogRootInShadowDom = (root === null || root === void 0 ? void 0 : root.getRootNode()) instanceof ShadowRoot;
124
+ // String-based type checking: Use constructor.name to identify ShadowRoot
125
+ // This avoids direct ShadowRoot type dependency while being more explicit than duck typing
126
+ const isDialogRootInShadowDom = typeof ShadowRoot !== 'undefined' && (root === null || root === void 0 ? void 0 : root.getRootNode()) instanceof ShadowRoot;
125
127
  const modalRef = (0, react_1.useRef)(null);
126
128
  const composedRef = ref ? (0, react_compose_refs_1.composeRefs)(ref, modalRef) : modalRef;
127
129
  const { isOpen, doClose, doOpen } = useModalOpenState(isInitiallyOpen, onOpen, onClose);
@@ -197,8 +197,10 @@ function AppContent({ rootContainer, routerBaseName, globalProps, standalone, tr
197
197
  var _a;
198
198
  if (!rootNode)
199
199
  return;
200
- // --- If element is in shadow DOM
201
- if (rootNode instanceof ShadowRoot) {
200
+ // --- If element is in shadow DOM (string-based type checking)
201
+ // --- Check constructor.name to avoid direct ShadowRoot type dependency
202
+ // --- More precise than duck typing, works reliably across different environments
203
+ if (typeof ShadowRoot !== 'undefined' && rootNode instanceof ShadowRoot) {
202
204
  const el = rootNode.getElementById(lastHash.current);
203
205
  if (!el)
204
206
  return;
@@ -281,7 +283,10 @@ function AppContent({ rootContainer, routerBaseName, globalProps, standalone, tr
281
283
  environment,
282
284
  mediaSize,
283
285
  queryClient: AppRoot_1.queryClient,
284
- standalone, appIsInShadowDom: (root === null || root === void 0 ? void 0 : root.getRootNode()) instanceof ShadowRoot }, date_functions_1.dateFunctions), math_function_1.mathFunctions), {
286
+ standalone,
287
+ // String-based type checking: Use constructor.name to identify ShadowRoot
288
+ // This avoids direct ShadowRoot type dependency while being more explicit than duck typing
289
+ appIsInShadowDom: typeof ShadowRoot !== 'undefined' && (root === null || root === void 0 ? void 0 : root.getRootNode()) instanceof ShadowRoot }, date_functions_1.dateFunctions), math_function_1.mathFunctions), {
285
290
  // --- File Utilities
286
291
  formatFileSizeInBytes: misc_1.formatFileSizeInBytes,
287
292
  getFileExtension: misc_1.getFileExtension,