@inertiaui/vanilla 0.3.0 → 0.4.0

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.d.ts CHANGED
@@ -79,6 +79,8 @@ export declare interface MenuNavigationOptions {
79
79
  onActivate?: (item: HTMLElement) => void;
80
80
  }
81
81
 
82
+ export declare function onceChildrenRendered(element: Element, callback: () => void): void;
83
+
82
84
  export declare function onClickOutside(elements: HTMLElement | HTMLElement[], callback: (event: PointerEvent) => void): CleanupFunction;
83
85
 
84
86
  export declare function onEscapeKey(callback: (event: KeyboardEvent) => void, options?: EscapeKeyOptions): CleanupFunction;
package/dist/index.js CHANGED
@@ -65,6 +65,19 @@ function isStandardDomEvent(eventName) {
65
65
  ];
66
66
  return standardPatterns.some((pattern) => pattern.test(lowerEventName));
67
67
  }
68
+ function onceChildrenRendered(element, callback) {
69
+ if (element.children.length > 0) {
70
+ callback();
71
+ return;
72
+ }
73
+ const observer = new MutationObserver(() => {
74
+ if (element.children.length > 0) {
75
+ observer.disconnect();
76
+ callback();
77
+ }
78
+ });
79
+ observer.observe(element, { childList: true });
80
+ }
68
81
  function sameUrlPath(url1, url2) {
69
82
  if (!url1 || !url2) {
70
83
  return false;
@@ -722,6 +735,7 @@ export {
722
735
  markAriaHidden,
723
736
  onClickOutside,
724
737
  onEscapeKey,
738
+ onceChildrenRendered,
725
739
  only,
726
740
  rejectNullValues,
727
741
  sameUrlPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inertiaui/vanilla",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "author": "Pascal Baljet <pascal@protone.media>",
5
5
  "private": false,
6
6
  "license": "MIT",