@solid2-aria/core 0.0.1 → 0.1.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.
Files changed (141) hide show
  1. package/README.md +14 -0
  2. package/dist/NOTICE.txt +33 -11
  3. package/dist/browser/actiongroup/create-action-group.js +2 -1
  4. package/dist/browser/actiongroup/create-action-group.js.map +1 -1
  5. package/dist/browser/combobox/create-combo-box.js +2 -2
  6. package/dist/browser/combobox/create-combo-box.js.map +1 -1
  7. package/dist/browser/dnd/drag-preview.js +7 -8
  8. package/dist/browser/dnd/drag-preview.js.map +1 -1
  9. package/dist/browser/focus/focus-scope.js +2 -2
  10. package/dist/browser/focus/focus-scope.js.map +1 -1
  11. package/dist/browser/focus/virtual-focus.d.ts +1 -0
  12. package/dist/browser/focus/virtual-focus.js +20 -5
  13. package/dist/browser/focus/virtual-focus.js.map +1 -1
  14. package/dist/browser/grid/create-grid-cell.js +4 -4
  15. package/dist/browser/grid/create-grid-cell.js.map +1 -1
  16. package/dist/browser/gridlist/create-grid-list-item.js +3 -3
  17. package/dist/browser/gridlist/create-grid-list-item.js.map +1 -1
  18. package/dist/browser/interactions/create-hover.js +6 -3
  19. package/dist/browser/interactions/create-hover.js.map +1 -1
  20. package/dist/browser/interactions/create-press.js +5 -4
  21. package/dist/browser/interactions/create-press.js.map +1 -1
  22. package/dist/browser/interactions/utils.js +4 -3
  23. package/dist/browser/interactions/utils.js.map +1 -1
  24. package/dist/browser/landmark/create-landmark.js +2 -2
  25. package/dist/browser/landmark/create-landmark.js.map +1 -1
  26. package/dist/browser/overlays/aria-hide-outside.js +5 -3
  27. package/dist/browser/overlays/aria-hide-outside.js.map +1 -1
  28. package/dist/browser/overlays/calculate-position.js +3 -3
  29. package/dist/browser/overlays/calculate-position.js.map +1 -1
  30. package/dist/browser/overlays/create-modal.js +15 -18
  31. package/dist/browser/overlays/create-modal.js.map +1 -1
  32. package/dist/browser/overlays/create-prevent-scroll.js +3 -3
  33. package/dist/browser/overlays/create-prevent-scroll.js.map +1 -1
  34. package/dist/browser/overlays/overlay.js +7 -8
  35. package/dist/browser/overlays/overlay.js.map +1 -1
  36. package/dist/browser/select/create-select.js +1 -1
  37. package/dist/browser/select/create-select.js.map +1 -1
  38. package/dist/browser/select/hidden-select.js +61 -64
  39. package/dist/browser/select/hidden-select.js.map +1 -1
  40. package/dist/browser/selection/create-selectable-item.js +2 -2
  41. package/dist/browser/selection/create-selectable-item.js.map +1 -1
  42. package/dist/browser/selection/create-type-select.js +11 -3
  43. package/dist/browser/selection/create-type-select.js.map +1 -1
  44. package/dist/browser/selection/list-keyboard-delegate.js +1 -1
  45. package/dist/browser/selection/list-keyboard-delegate.js.map +1 -1
  46. package/dist/browser/tokenfield/create-token-field.js +3 -3
  47. package/dist/browser/tokenfield/create-token-field.js.map +1 -1
  48. package/dist/browser/tokenfield/create-token.js +2 -1
  49. package/dist/browser/tokenfield/create-token.js.map +1 -1
  50. package/dist/browser/toolbar/create-toolbar.js +2 -2
  51. package/dist/browser/toolbar/create-toolbar.js.map +1 -1
  52. package/dist/browser/utils/dom-helpers.d.ts +2 -15
  53. package/dist/browser/utils/dom-helpers.js +1 -28
  54. package/dist/browser/utils/dom-helpers.js.map +1 -1
  55. package/dist/browser/utils/dom-value.js +2 -1
  56. package/dist/browser/utils/dom-value.js.map +1 -1
  57. package/dist/browser/utils/get-scroll-parent.js +3 -2
  58. package/dist/browser/utils/get-scroll-parent.js.map +1 -1
  59. package/dist/browser/utils/get-scroll-parents.js +2 -1
  60. package/dist/browser/utils/get-scroll-parents.js.map +1 -1
  61. package/dist/browser/utils/is-element-visible.js +3 -1
  62. package/dist/browser/utils/is-element-visible.js.map +1 -1
  63. package/dist/browser/utils/is-focusable.js +2 -1
  64. package/dist/browser/utils/is-focusable.js.map +1 -1
  65. package/dist/browser/utils/shadowdom/dom-functions.d.ts +8 -0
  66. package/dist/browser/utils/shadowdom/dom-functions.js +26 -7
  67. package/dist/browser/utils/shadowdom/dom-functions.js.map +1 -1
  68. package/dist/browser/utils/shadowdom/shadow-tree-walker.js +1 -1
  69. package/dist/browser/utils/shadowdom/shadow-tree-walker.js.map +1 -1
  70. package/dist/browser/utils/type-helpers.d.ts +42 -0
  71. package/dist/browser/utils/type-helpers.js +55 -0
  72. package/dist/browser/utils/type-helpers.js.map +1 -0
  73. package/dist/server/actiongroup/create-action-group.js +2 -1
  74. package/dist/server/actiongroup/create-action-group.js.map +1 -1
  75. package/dist/server/combobox/create-combo-box.js +2 -2
  76. package/dist/server/combobox/create-combo-box.js.map +1 -1
  77. package/dist/server/dnd/drag-preview.js +9 -12
  78. package/dist/server/dnd/drag-preview.js.map +1 -1
  79. package/dist/server/focus/focus-scope.js +2 -2
  80. package/dist/server/focus/focus-scope.js.map +1 -1
  81. package/dist/server/focus/virtual-focus.js +20 -5
  82. package/dist/server/focus/virtual-focus.js.map +1 -1
  83. package/dist/server/grid/create-grid-cell.js +4 -4
  84. package/dist/server/grid/create-grid-cell.js.map +1 -1
  85. package/dist/server/gridlist/create-grid-list-item.js +3 -3
  86. package/dist/server/gridlist/create-grid-list-item.js.map +1 -1
  87. package/dist/server/interactions/create-hover.js +6 -3
  88. package/dist/server/interactions/create-hover.js.map +1 -1
  89. package/dist/server/interactions/create-press.js +5 -4
  90. package/dist/server/interactions/create-press.js.map +1 -1
  91. package/dist/server/interactions/utils.js +4 -3
  92. package/dist/server/interactions/utils.js.map +1 -1
  93. package/dist/server/landmark/create-landmark.js +2 -2
  94. package/dist/server/landmark/create-landmark.js.map +1 -1
  95. package/dist/server/overlays/aria-hide-outside.js +5 -3
  96. package/dist/server/overlays/aria-hide-outside.js.map +1 -1
  97. package/dist/server/overlays/calculate-position.js +3 -3
  98. package/dist/server/overlays/calculate-position.js.map +1 -1
  99. package/dist/server/overlays/create-modal.js +7 -27
  100. package/dist/server/overlays/create-modal.js.map +1 -1
  101. package/dist/server/overlays/create-prevent-scroll.js +3 -3
  102. package/dist/server/overlays/create-prevent-scroll.js.map +1 -1
  103. package/dist/server/overlays/overlay.js +8 -18
  104. package/dist/server/overlays/overlay.js.map +1 -1
  105. package/dist/server/select/create-select.js +1 -1
  106. package/dist/server/select/create-select.js.map +1 -1
  107. package/dist/server/select/hidden-select.js +85 -138
  108. package/dist/server/select/hidden-select.js.map +1 -1
  109. package/dist/server/selection/create-selectable-item.js +2 -2
  110. package/dist/server/selection/create-selectable-item.js.map +1 -1
  111. package/dist/server/selection/create-type-select.js +11 -3
  112. package/dist/server/selection/create-type-select.js.map +1 -1
  113. package/dist/server/selection/list-keyboard-delegate.js +1 -1
  114. package/dist/server/selection/list-keyboard-delegate.js.map +1 -1
  115. package/dist/server/tokenfield/create-token-field.js +3 -3
  116. package/dist/server/tokenfield/create-token-field.js.map +1 -1
  117. package/dist/server/tokenfield/create-token.js +2 -1
  118. package/dist/server/tokenfield/create-token.js.map +1 -1
  119. package/dist/server/toolbar/create-toolbar.js +2 -2
  120. package/dist/server/toolbar/create-toolbar.js.map +1 -1
  121. package/dist/server/utils/dom-helpers.js +1 -28
  122. package/dist/server/utils/dom-helpers.js.map +1 -1
  123. package/dist/server/utils/dom-value.js +2 -1
  124. package/dist/server/utils/dom-value.js.map +1 -1
  125. package/dist/server/utils/get-scroll-parent.js +3 -2
  126. package/dist/server/utils/get-scroll-parent.js.map +1 -1
  127. package/dist/server/utils/get-scroll-parents.js +2 -1
  128. package/dist/server/utils/get-scroll-parents.js.map +1 -1
  129. package/dist/server/utils/is-element-visible.js +3 -1
  130. package/dist/server/utils/is-element-visible.js.map +1 -1
  131. package/dist/server/utils/is-focusable.js +2 -1
  132. package/dist/server/utils/is-focusable.js.map +1 -1
  133. package/dist/server/utils/shadowdom/dom-functions.js +26 -7
  134. package/dist/server/utils/shadowdom/dom-functions.js.map +1 -1
  135. package/dist/server/utils/shadowdom/shadow-tree-walker.js +1 -1
  136. package/dist/server/utils/shadowdom/shadow-tree-walker.js.map +1 -1
  137. package/dist/server/utils/type-helpers.js +55 -0
  138. package/dist/server/utils/type-helpers.js.map +1 -0
  139. package/dist/server/virtualizer/scroll-view.js +3 -1
  140. package/dist/server/virtualizer/scroll-view.js.map +1 -1
  141. package/package.json +16 -10
@@ -1 +1 @@
1
- {"version":3,"file":"get-scroll-parents.js","names":[],"sources":["../../../src/utils/get-scroll-parents.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/utils/getScrollParents.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { isScrollable } from \"./is-scrollable\";\nimport { getTruthyValue, isTruthy } from \"./truthy\";\n\nexport function getScrollParents(\n node: Element,\n checkForOverflow?: boolean\n): Element[] {\n let currentNode: Element | null = node;\n\n const parentElements: Element[] = [];\n\n const root =\n getTruthyValue(document.scrollingElement) ?? document.documentElement;\n\n while (isTruthy(currentNode)) {\n if (isScrollable(currentNode, checkForOverflow)) {\n parentElements.push(currentNode);\n }\n\n if (currentNode === root) {\n break;\n }\n\n currentNode = currentNode.parentElement;\n }\n\n return parentElements;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,iBACd,MACA,kBACW;CACX,IAAI,cAA8B;CAElC,MAAM,iBAA4B,CAAC;CAEnC,MAAM,OACJ,eAAe,SAAS,gBAAgB,KAAK,SAAS;CAExD,OAAO,SAAS,WAAW,GAAG;EAC5B,IAAI,aAAa,aAAa,gBAAgB,GAC5C,eAAe,KAAK,WAAW;EAGjC,IAAI,gBAAgB,MAClB;EAGF,cAAc,YAAY;CAC5B;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"get-scroll-parents.js","names":[],"sources":["../../../src/utils/get-scroll-parents.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/utils/getScrollParents.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { isScrollable } from \"./is-scrollable\";\nimport { getParentElement } from \"./shadowdom/dom-functions\";\nimport { getTruthyValue, isTruthy } from \"./truthy\";\n\nexport function getScrollParents(\n node: Element,\n checkForOverflow?: boolean\n): Element[] {\n let currentNode: Element | null = node;\n\n const parentElements: Element[] = [];\n\n const root =\n getTruthyValue(document.scrollingElement) ?? document.documentElement;\n\n while (isTruthy(currentNode)) {\n if (isScrollable(currentNode, checkForOverflow)) {\n parentElements.push(currentNode);\n }\n\n if (currentNode === root) {\n break;\n }\n\n currentNode = getParentElement(currentNode);\n }\n\n return parentElements;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,iBACd,MACA,kBACW;CACX,IAAI,cAA8B;CAElC,MAAM,iBAA4B,CAAC;CAEnC,MAAM,OACJ,eAAe,SAAS,gBAAgB,KAAK,SAAS;CAExD,OAAO,SAAS,WAAW,GAAG;EAC5B,IAAI,aAAa,aAAa,gBAAgB,GAC5C,eAAe,KAAK,WAAW;EAGjC,IAAI,gBAAgB,MAClB;EAGF,cAAc,iBAAiB,WAAW;CAC5C;CAEA,OAAO;AACT"}
@@ -15,6 +15,7 @@
15
15
  * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
16
16
  */
17
17
  import { getOwnerWindow } from "./dom-helpers.js";
18
+ import { getParentElement } from "./shadowdom/dom-functions.js";
18
19
  // src/utils/is-element-visible.ts
19
20
  /**
20
21
  * Adapted from https://github.com/testing-library/jest-dom and
@@ -40,7 +41,8 @@ function isAttributeVisible(element, childElement) {
40
41
  }
41
42
  function isElementVisible(element, childElement) {
42
43
  if (supportsCheckVisibility) return element.checkVisibility({ visibilityProperty: true }) && !element.closest("[data-react-aria-prevent-focus]");
43
- return element.nodeName !== "#comment" && isStyleVisible(element) && isAttributeVisible(element, childElement) && (!element.parentElement || isElementVisible(element.parentElement, element));
44
+ const parentElement = getParentElement(element);
45
+ return element.nodeName !== "#comment" && isStyleVisible(element) && isAttributeVisible(element, childElement) && (!parentElement || isElementVisible(parentElement, element));
44
46
  }
45
47
  export { isElementVisible };
46
48
 
@@ -1 +1 @@
1
- {"version":3,"file":"is-element-visible.js","names":[],"sources":["../../../src/utils/is-element-visible.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/utils/isElementVisible.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\n/**\n * Adapted from https://github.com/testing-library/jest-dom and\n * https://github.com/vuejs/vue-test-utils-next/.\n * Licensed under the MIT License.\n *\n * @param element - Element to evaluate for display or visibility.\n */\n\nimport { getOwnerWindow } from \"./dom-helpers\";\n\nconst supportsCheckVisibility =\n typeof Element !== \"undefined\" && \"checkVisibility\" in Element.prototype;\n\nfunction isStyleVisible(element: Element) {\n const windowObject = getOwnerWindow(element);\n\n if (\n !(element instanceof windowObject.HTMLElement) &&\n !(element instanceof windowObject.SVGElement)\n ) {\n return false;\n }\n\n const { display, visibility } = element.style;\n\n let isVisible =\n display !== \"none\" && visibility !== \"hidden\" && visibility !== \"collapse\";\n\n if (isVisible) {\n const { display: computedDisplay, visibility: computedVisibility } =\n windowObject.getComputedStyle(element);\n\n isVisible =\n computedDisplay !== \"none\" &&\n computedVisibility !== \"hidden\" &&\n computedVisibility !== \"collapse\";\n }\n\n return isVisible;\n}\n\nfunction isAttributeVisible(element: Element, childElement?: Element) {\n return (\n !element.hasAttribute(\"hidden\") &&\n // Ignore HiddenSelect when tree walking.\n element.attributes.getNamedItem(\"data-react-aria-prevent-focus\") === null &&\n (element.nodeName === \"DETAILS\" &&\n childElement &&\n childElement.nodeName !== \"SUMMARY\"\n ? element.hasAttribute(\"open\")\n : true)\n );\n}\n\nexport function isElementVisible(\n element: Element,\n childElement?: Element\n): boolean {\n if (supportsCheckVisibility) {\n return (\n element.checkVisibility({ visibilityProperty: true }) &&\n !element.closest(\"[data-react-aria-prevent-focus]\")\n );\n }\n\n return (\n element.nodeName !== \"#comment\" &&\n isStyleVisible(element) &&\n isAttributeVisible(element, childElement) &&\n (!element.parentElement || isElementVisible(element.parentElement, element))\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,0BACJ,OAAO,YAAY,eAAe,qBAAqB,QAAQ;AAEjE,SAAS,eAAe,SAAkB;CACxC,MAAM,eAAe,eAAe,OAAO;CAE3C,IACE,EAAE,mBAAmB,aAAa,gBAClC,EAAE,mBAAmB,aAAa,aAElC,OAAO;CAGT,MAAM,EAAE,SAAS,eAAe,QAAQ;CAExC,IAAI,YACF,YAAY,UAAU,eAAe,YAAY,eAAe;CAElE,IAAI,WAAW;EACb,MAAM,EAAE,SAAS,iBAAiB,YAAY,uBAC5C,aAAa,iBAAiB,OAAO;EAEvC,YACE,oBAAoB,UACpB,uBAAuB,YACvB,uBAAuB;CAC3B;CAEA,OAAO;AACT;AAEA,SAAS,mBAAmB,SAAkB,cAAwB;CACpE,OACE,CAAC,QAAQ,aAAa,QAAQ,KAE9B,QAAQ,WAAW,aAAa,+BAA+B,MAAM,SACpE,QAAQ,aAAa,aACtB,gBACA,aAAa,aAAa,YACtB,QAAQ,aAAa,MAAM,IAC3B;AAER;AAEA,SAAgB,iBACd,SACA,cACS;CACT,IAAI,yBACF,OACE,QAAQ,gBAAgB,EAAE,oBAAoB,KAAK,CAAC,KACpD,CAAC,QAAQ,QAAQ,iCAAiC;CAItD,OACE,QAAQ,aAAa,cACrB,eAAe,OAAO,KACtB,mBAAmB,SAAS,YAAY,MACvC,CAAC,QAAQ,iBAAiB,iBAAiB,QAAQ,eAAe,OAAO;AAE9E"}
1
+ {"version":3,"file":"is-element-visible.js","names":[],"sources":["../../../src/utils/is-element-visible.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/utils/isElementVisible.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\n/**\n * Adapted from https://github.com/testing-library/jest-dom and\n * https://github.com/vuejs/vue-test-utils-next/.\n * Licensed under the MIT License.\n *\n * @param element - Element to evaluate for display or visibility.\n */\n\nimport { getOwnerWindow } from \"./dom-helpers\";\nimport { getParentElement } from \"./shadowdom/dom-functions\";\n\nconst supportsCheckVisibility =\n typeof Element !== \"undefined\" && \"checkVisibility\" in Element.prototype;\n\nfunction isStyleVisible(element: Element) {\n const windowObject = getOwnerWindow(element);\n\n if (\n !(element instanceof windowObject.HTMLElement) &&\n !(element instanceof windowObject.SVGElement)\n ) {\n return false;\n }\n\n const { display, visibility } = element.style;\n\n let isVisible =\n display !== \"none\" && visibility !== \"hidden\" && visibility !== \"collapse\";\n\n if (isVisible) {\n const { display: computedDisplay, visibility: computedVisibility } =\n windowObject.getComputedStyle(element);\n\n isVisible =\n computedDisplay !== \"none\" &&\n computedVisibility !== \"hidden\" &&\n computedVisibility !== \"collapse\";\n }\n\n return isVisible;\n}\n\nfunction isAttributeVisible(element: Element, childElement?: Element) {\n return (\n !element.hasAttribute(\"hidden\") &&\n // Ignore HiddenSelect when tree walking.\n element.attributes.getNamedItem(\"data-react-aria-prevent-focus\") === null &&\n (element.nodeName === \"DETAILS\" &&\n childElement &&\n childElement.nodeName !== \"SUMMARY\"\n ? element.hasAttribute(\"open\")\n : true)\n );\n}\n\nexport function isElementVisible(\n element: Element,\n childElement?: Element\n): boolean {\n if (supportsCheckVisibility) {\n return (\n element.checkVisibility({ visibilityProperty: true }) &&\n !element.closest(\"[data-react-aria-prevent-focus]\")\n );\n }\n\n const parentElement = getParentElement(element);\n\n return (\n element.nodeName !== \"#comment\" &&\n isStyleVisible(element) &&\n isAttributeVisible(element, childElement) &&\n (!parentElement || isElementVisible(parentElement, element))\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,0BACJ,OAAO,YAAY,eAAe,qBAAqB,QAAQ;AAEjE,SAAS,eAAe,SAAkB;CACxC,MAAM,eAAe,eAAe,OAAO;CAE3C,IACE,EAAE,mBAAmB,aAAa,gBAClC,EAAE,mBAAmB,aAAa,aAElC,OAAO;CAGT,MAAM,EAAE,SAAS,eAAe,QAAQ;CAExC,IAAI,YACF,YAAY,UAAU,eAAe,YAAY,eAAe;CAElE,IAAI,WAAW;EACb,MAAM,EAAE,SAAS,iBAAiB,YAAY,uBAC5C,aAAa,iBAAiB,OAAO;EAEvC,YACE,oBAAoB,UACpB,uBAAuB,YACvB,uBAAuB;CAC3B;CAEA,OAAO;AACT;AAEA,SAAS,mBAAmB,SAAkB,cAAwB;CACpE,OACE,CAAC,QAAQ,aAAa,QAAQ,KAE9B,QAAQ,WAAW,aAAa,+BAA+B,MAAM,SACpE,QAAQ,aAAa,aACtB,gBACA,aAAa,aAAa,YACtB,QAAQ,aAAa,MAAM,IAC3B;AAER;AAEA,SAAgB,iBACd,SACA,cACS;CACT,IAAI,yBACF,OACE,QAAQ,gBAAgB,EAAE,oBAAoB,KAAK,CAAC,KACpD,CAAC,QAAQ,QAAQ,iCAAiC;CAItD,MAAM,gBAAgB,iBAAiB,OAAO;CAE9C,OACE,QAAQ,aAAa,cACrB,eAAe,OAAO,KACtB,mBAAmB,SAAS,YAAY,MACvC,CAAC,iBAAiB,iBAAiB,eAAe,OAAO;AAE9D"}
@@ -17,6 +17,7 @@
17
17
  import { getTruthyValue, whenTruthy } from "./truthy.js";
18
18
  import { isPresent } from "./is-present.js";
19
19
  import { getOwnerWindow } from "./dom-helpers.js";
20
+ import { getParentElement } from "./shadowdom/dom-functions.js";
20
21
  import { isElementVisible } from "./is-element-visible.js";
21
22
  // src/utils/is-focusable.ts
22
23
  const focusableElements = [
@@ -48,7 +49,7 @@ function isInert(element) {
48
49
  let node = element;
49
50
  while (isPresent(node)) {
50
51
  if (node instanceof getOwnerWindow(node).HTMLElement && node.inert) return true;
51
- node = node.parentElement;
52
+ node = getParentElement(node);
52
53
  }
53
54
  return false;
54
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"is-focusable.js","names":[],"sources":["../../../src/utils/is-focusable.ts"],"sourcesContent":["/*\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/utils/isFocusable.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { getOwnerWindow } from \"./dom-helpers\";\nimport { isElementVisible } from \"./is-element-visible\";\nimport { isPresent } from \"./is-present\";\nimport { getTruthyValue, whenTruthy } from \"./truthy\";\n\nconst focusableElements = [\n \"input:not([disabled]):not([type=hidden])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n \"button:not([disabled])\",\n \"a[href]\",\n \"area[href]\",\n \"summary\",\n \"iframe\",\n \"object\",\n \"embed\",\n \"audio[controls]\",\n \"video[controls]\",\n '[contenteditable]:not([contenteditable^=\"false\"])',\n \"permission\",\n];\n\nconst FOCUSABLE_ELEMENT_SELECTOR = `${focusableElements.join(\n \":not([hidden]),\"\n)},[tabindex]:not([disabled]):not([hidden])`;\n\nfocusableElements.push('[tabindex]:not([tabindex=\"-1\"]):not([disabled])');\n\nconst TABBABLE_ELEMENT_SELECTOR = focusableElements.join(\n ':not([hidden]):not([tabindex=\"-1\"]),'\n);\n\nexport function isFocusable(\n element: Element,\n options?: {\n skipVisibilityCheck?: boolean;\n }\n): boolean {\n return whenTruthy(\n whenTruthy(\n element.matches(FOCUSABLE_ELEMENT_SELECTOR),\n () => !isInert(element)\n ),\n () =>\n getTruthyValue(options?.skipVisibilityCheck) ?? isElementVisible(element)\n );\n}\n\nexport function isTabbable(element: Element): boolean {\n return (\n element.matches(TABBABLE_ELEMENT_SELECTOR) &&\n isElementVisible(element) &&\n !isInert(element)\n );\n}\n\nfunction isInert(element: Element): boolean {\n let node: Element | null = element;\n\n while (isPresent(node)) {\n if (node instanceof getOwnerWindow(node).HTMLElement && node.inert) {\n return true;\n }\n\n node = node.parentElement;\n }\n\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,6BAA6B,GAAG,kBAAkB,KACtD,iBACF,EAAE;AAEF,kBAAkB,KAAK,mDAAiD;AAExE,MAAM,4BAA4B,kBAAkB,KAClD,wCACF;AAEA,SAAgB,YACd,SACA,SAGS;CACT,OAAO,WACL,WACE,QAAQ,QAAQ,0BAA0B,SACpC,CAAC,QAAQ,OAAO,CACxB,SAEE,eAAe,SAAS,mBAAmB,KAAK,iBAAiB,OAAO,CAC5E;AACF;AAEA,SAAgB,WAAW,SAA2B;CACpD,OACE,QAAQ,QAAQ,yBAAyB,KACzC,iBAAiB,OAAO,KACxB,CAAC,QAAQ,OAAO;AAEpB;AAEA,SAAS,QAAQ,SAA2B;CAC1C,IAAI,OAAuB;CAE3B,OAAO,UAAU,IAAI,GAAG;EACtB,IAAI,gBAAgB,eAAe,IAAI,CAAC,CAAC,eAAe,KAAK,OAC3D,OAAO;EAGT,OAAO,KAAK;CACd;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"is-focusable.js","names":[],"sources":["../../../src/utils/is-focusable.ts"],"sourcesContent":["/*\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/utils/isFocusable.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { getOwnerWindow } from \"./dom-helpers\";\nimport { isElementVisible } from \"./is-element-visible\";\nimport { isPresent } from \"./is-present\";\nimport { getParentElement } from \"./shadowdom/dom-functions\";\nimport { getTruthyValue, whenTruthy } from \"./truthy\";\n\nconst focusableElements = [\n \"input:not([disabled]):not([type=hidden])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n \"button:not([disabled])\",\n \"a[href]\",\n \"area[href]\",\n \"summary\",\n \"iframe\",\n \"object\",\n \"embed\",\n \"audio[controls]\",\n \"video[controls]\",\n '[contenteditable]:not([contenteditable^=\"false\"])',\n \"permission\",\n];\n\nconst FOCUSABLE_ELEMENT_SELECTOR = `${focusableElements.join(\n \":not([hidden]),\"\n)},[tabindex]:not([disabled]):not([hidden])`;\n\nfocusableElements.push('[tabindex]:not([tabindex=\"-1\"]):not([disabled])');\n\nconst TABBABLE_ELEMENT_SELECTOR = focusableElements.join(\n ':not([hidden]):not([tabindex=\"-1\"]),'\n);\n\nexport function isFocusable(\n element: Element,\n options?: {\n skipVisibilityCheck?: boolean;\n }\n): boolean {\n return whenTruthy(\n whenTruthy(\n element.matches(FOCUSABLE_ELEMENT_SELECTOR),\n () => !isInert(element)\n ),\n () =>\n getTruthyValue(options?.skipVisibilityCheck) ?? isElementVisible(element)\n );\n}\n\nexport function isTabbable(element: Element): boolean {\n return (\n element.matches(TABBABLE_ELEMENT_SELECTOR) &&\n isElementVisible(element) &&\n !isInert(element)\n );\n}\n\nfunction isInert(element: Element): boolean {\n let node: Element | null = element;\n\n while (isPresent(node)) {\n if (node instanceof getOwnerWindow(node).HTMLElement && node.inert) {\n return true;\n }\n\n node = getParentElement(node);\n }\n\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,6BAA6B,GAAG,kBAAkB,KACtD,iBACF,EAAE;AAEF,kBAAkB,KAAK,mDAAiD;AAExE,MAAM,4BAA4B,kBAAkB,KAClD,wCACF;AAEA,SAAgB,YACd,SACA,SAGS;CACT,OAAO,WACL,WACE,QAAQ,QAAQ,0BAA0B,SACpC,CAAC,QAAQ,OAAO,CACxB,SAEE,eAAe,SAAS,mBAAmB,KAAK,iBAAiB,OAAO,CAC5E;AACF;AAEA,SAAgB,WAAW,SAA2B;CACpD,OACE,QAAQ,QAAQ,yBAAyB,KACzC,iBAAiB,OAAO,KACxB,CAAC,QAAQ,OAAO;AAEpB;AAEA,SAAS,QAAQ,SAA2B;CAC1C,IAAI,OAAuB;CAE3B,OAAO,UAAU,IAAI,GAAG;EACtB,IAAI,gBAAgB,eAAe,IAAI,CAAC,CAAC,eAAe,KAAK,OAC3D,OAAO;EAGT,OAAO,iBAAiB,IAAI;CAC9B;CAEA,OAAO;AACT"}
@@ -4,6 +4,14 @@
4
4
  * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
5
5
  */
6
6
  import { EventTargetType } from "@solid2-aria/types-shared";
7
+ /**
8
+ * ShadowDOM safe version of Node.parentNode.
9
+ */
10
+ export declare function getParentNode(node: Node | null | undefined): Node | null;
11
+ /**
12
+ * ShadowDOM safe version of element.parentElement.
13
+ */
14
+ export declare function getParentElement(node: Node | null | undefined): Element | null;
7
15
  /**
8
16
  * ShadowDOM safe version of Node.contains.
9
17
  */
@@ -4,22 +4,41 @@
4
4
  * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
5
5
  */
6
6
  import { isPresent } from "../is-present.js";
7
- import { getOwnerWindow, isNode, isShadowRoot } from "../dom-helpers.js";
7
+ import { isElement, isNode, isShadowRoot } from "../type-helpers.js";
8
+ import { getOwnerWindow } from "../dom-helpers.js";
8
9
  import { shadowDOM } from "@solid2-aria/stately/flags/flags";
9
10
  // src/utils/shadowdom/dom-functions.ts
10
11
  /**
12
+ * ShadowDOM safe version of Node.parentNode.
13
+ */
14
+ function getParentNode(node) {
15
+ if (!shadowDOM()) return node?.parentNode ?? null;
16
+ if (!node) return null;
17
+ let currentNode = node;
18
+ const assignedSlot = "assignedSlot" in currentNode ? currentNode.assignedSlot : null;
19
+ if ((!("assignedElements" in currentNode) || typeof currentNode.assignedElements !== "function") && assignedSlot instanceof getOwnerWindow(currentNode).HTMLSlotElement && assignedSlot.parentNode) currentNode = assignedSlot.parentNode;
20
+ else if (isShadowRoot(currentNode)) currentNode = currentNode.host;
21
+ else currentNode = currentNode.parentNode;
22
+ return currentNode;
23
+ }
24
+ /**
25
+ * ShadowDOM safe version of element.parentElement.
26
+ */
27
+ function getParentElement(node) {
28
+ let parentNode = getParentNode(node);
29
+ while (parentNode && !isElement(parentNode)) parentNode = getParentNode(parentNode);
30
+ return parentNode;
31
+ }
32
+ /**
11
33
  * ShadowDOM safe version of Node.contains.
12
34
  */
13
35
  function nodeContains(node, otherNode) {
14
36
  if (!isNode(node) || !isNode(otherNode)) return false;
15
37
  if (!shadowDOM()) return node.contains(otherNode);
16
38
  let currentNode = otherNode;
17
- while (isPresent(currentNode)) {
39
+ while (currentNode) {
18
40
  if (currentNode === node) return true;
19
- const assignedSlot = "assignedSlot" in currentNode ? currentNode.assignedSlot : null;
20
- if ((!("assignedElements" in currentNode) || typeof currentNode.assignedElements !== "function") && assignedSlot instanceof getOwnerWindow(currentNode).HTMLSlotElement && assignedSlot.parentNode) currentNode = assignedSlot.parentNode;
21
- else if (isShadowRoot(currentNode)) currentNode = currentNode.host;
22
- else currentNode = currentNode.parentNode;
41
+ currentNode = getParentNode(currentNode);
23
42
  }
24
43
  return false;
25
44
  }
@@ -75,6 +94,6 @@ function isFocusWithin(node) {
75
94
  const { activeElement } = root;
76
95
  return isPresent(activeElement) && node.contains(activeElement);
77
96
  }
78
- export { getActiveElement, getEventTarget, getPropagationTargets, isFocusWithin, nodeContains };
97
+ export { getActiveElement, getEventTarget, getParentElement, getParentNode, getPropagationTargets, isFocusWithin, nodeContains };
79
98
 
80
99
  //# sourceMappingURL=dom-functions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dom-functions.js","names":[],"sources":["../../../../src/utils/shadowdom/dom-functions.ts"],"sourcesContent":["/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/utils/shadowdom/DOMFunctions.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { shadowDOM } from \"@solid2-aria/stately/flags/flags\";\nimport type { EventTargetType } from \"@solid2-aria/types-shared\";\n\nimport { getOwnerWindow, isShadowRoot, isNode } from \"../dom-helpers\";\nimport { isPresent } from \"../is-present\";\n\n// Source: https://github.com/microsoft/tabster/blob/a89fc5d7e332d48f68d03b1ca6e344489d1c3898/src/Shadowdomize/DOMFunctions.ts#L16\n\n/**\n * ShadowDOM safe version of Node.contains.\n */\nexport function nodeContains(\n node: EventTarget | null | undefined,\n otherNode: EventTarget | null | undefined\n): boolean {\n if (!isNode(node) || !isNode(otherNode)) {\n return false;\n }\n\n if (!shadowDOM()) {\n return node.contains(otherNode);\n }\n\n let currentNode: HTMLElement | Node | null | undefined = otherNode;\n\n while (isPresent(currentNode)) {\n if (currentNode === node) {\n return true;\n }\n\n const assignedSlot: unknown =\n \"assignedSlot\" in currentNode ? currentNode.assignedSlot : null;\n\n if (\n (!(\"assignedElements\" in currentNode) ||\n typeof currentNode.assignedElements !== \"function\") &&\n assignedSlot instanceof getOwnerWindow(currentNode).HTMLSlotElement &&\n assignedSlot.parentNode\n ) {\n // Element is slotted.\n currentNode = assignedSlot.parentNode;\n } else if (isShadowRoot(currentNode)) {\n // Element is in shadow root\n currentNode = currentNode.host;\n } else {\n currentNode = currentNode.parentNode;\n }\n }\n\n return false;\n}\n\n/**\n * ShadowDOM safe version of document.activeElement.\n */\nexport const getActiveElement = (doc: Document = document): Element | null => {\n if (!shadowDOM()) {\n return doc.activeElement;\n }\n\n let activeElement: Element | null = doc.activeElement;\n\n while (\n activeElement &&\n \"shadowRoot\" in activeElement &&\n activeElement.shadowRoot?.activeElement\n ) {\n ({ activeElement } = activeElement.shadowRoot);\n }\n\n return activeElement;\n};\n\n// Possibly we can improve the types for this using https://github.com/adobe/react-spectrum/pull/8991/changes#diff-2d491c0c91701d28d08e1cf9fcadbdb21a030b67ab681460c9934140f29127b8R68 but it was more changes than I\n// wanted to make to fix the function.\n/**\n * ShadowDOM safe version of event.target.\n */\ntype ResolvedEventTarget<T> =\n unknown extends EventTargetType<T> ? EventTarget | null : EventTargetType<T>;\n\nexport function getEventTarget<T extends Event>(\n event: T\n): ResolvedEventTarget<T> {\n let { target } = event;\n\n if (\n shadowDOM() &&\n target instanceof Element &&\n target.shadowRoot &&\n \"composedPath\" in event\n ) {\n target = event.composedPath()[0] ?? null;\n }\n\n // SAFETY: This preserves the event's target contract after resolving its composed path; erased targets retain the native nullable EventTarget type.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- TypeScript cannot derive this conditional event-target type from the runtime path.\n return target as ResolvedEventTarget<T>;\n}\n\n/**\n * Returns the set of event targets a listener must be attached to in order to\n * globally observe an event.\n *\n * @param from - The target element to start from.\n * @param to - The element to stop at when bubbling. @default getOwnerWindow(from)\n * `to` is generally going to be either `document` or `window`, but\n * it can be any intermediate node.\n * @returns [global, ...shadowRoots]\n */\nexport function getPropagationTargets(\n from: Element | Document | Window | null | undefined,\n to?: Document | Window | Element | null\n): EventTarget[] {\n let currentTo = to;\n\n // If `to` is coming from a ref, its type technically allows `null`.\n // In practice, this function will generally be called from within an effect.\n // If the ref has not resolved by that point, then a coding error has been made.\n // Better to return an empty array than `[window]`, which may appear to work\n // in the light DOM, but fail in the shadow DOM.\n if (currentTo === null) {\n return [];\n }\n\n currentTo ??= getOwnerWindow(from);\n const targets: EventTarget[] = [currentTo];\n\n if (!shadowDOM() || !from || from === currentTo) {\n return targets;\n }\n\n // The root `to` itself lives in. The event already reaches `to` once\n // it is inside this root, so we must NOT collect this root or anything above\n // it — only the shadow roots strictly between `refNode` and `to`.\n // `window` has no getRootNode; its boundary is the document, which the walk\n // reaches naturally (the document is not a ShadowRoot, so the loop exits).\n const toRoot = \"getRootNode\" in currentTo ? currentTo.getRootNode() : null;\n let current: Node | null = \"getRootNode\" in from ? from.getRootNode() : null;\n\n while (isShadowRoot(current) && current !== toRoot) {\n // order shouldn't matter\n targets.push(current);\n current = current.host.getRootNode();\n }\n\n return targets;\n}\n\n/**\n * ShadowDOM safe fast version of node.contains(document.activeElement).\n *\n * @param node - The element whose subtree may contain focus.\n * @returns Whether the element contains the active element.\n */\nexport function isFocusWithin(node: Element | null | undefined): boolean {\n if (!node) {\n return false;\n }\n\n // Get the active element within the node's parent shadow root (or the document). Can return null.\n const root = node.getRootNode();\n const ownerWindow = getOwnerWindow(node);\n\n if (\n !(root instanceof ownerWindow.Document) &&\n !(root instanceof ownerWindow.ShadowRoot)\n ) {\n return false;\n }\n\n const { activeElement } = root;\n\n // Check if the active element is within this node. These nodes are within the same shadow root.\n return isPresent(activeElement) && node.contains(activeElement);\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,SAAgB,aACd,MACA,WACS;CACT,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,SAAS,GACpC,OAAO;CAGT,IAAI,CAAC,UAAU,GACb,OAAO,KAAK,SAAS,SAAS;CAGhC,IAAI,cAAqD;CAEzD,OAAO,UAAU,WAAW,GAAG;EAC7B,IAAI,gBAAg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,aAC9B,EAAE,gBAAgB,YAAY,aAE9B,OAAO;CAGT,MAAM,EAAE,kBAAkB;CAG1B,OAAO,UAAU,aAAa,KAAK,KAAK,SAAS,aAAa;AAChE"}
1
+ {"version":3,"file":"dom-functions.js","names":[],"sources":["../../../../src/utils/shadowdom/dom-functions.ts"],"sourcesContent":["/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/utils/shadowdom/DOMFunctions.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { shadowDOM } from \"@solid2-aria/stately/flags/flags\";\nimport type { EventTargetType } from \"@solid2-aria/types-shared\";\n\nimport { getOwnerWindow } from \"../dom-helpers\";\nimport { isPresent } from \"../is-present\";\nimport { isElement, isShadowRoot, isNode } from \"../type-helpers\";\n\n// Source: https://github.com/microsoft/tabster/blob/a89fc5d7e332d48f68d03b1ca6e344489d1c3898/src/Shadowdomize/DOMFunctions.ts#L16\n\n/**\n * ShadowDOM safe version of Node.parentNode.\n */\nexport function getParentNode(node: Node | null | undefined): Node | null {\n if (!shadowDOM()) {\n return node?.parentNode ?? null;\n }\n\n if (!node) {\n return null;\n }\n\n let currentNode: Node | null = node;\n\n const assignedSlot: unknown =\n \"assignedSlot\" in currentNode ? currentNode.assignedSlot : null;\n\n if (\n (!(\"assignedElements\" in currentNode) ||\n typeof currentNode.assignedElements !== \"function\") &&\n assignedSlot instanceof getOwnerWindow(currentNode).HTMLSlotElement &&\n assignedSlot.parentNode\n ) {\n // Element is slotted.\n currentNode = assignedSlot.parentNode;\n } else if (isShadowRoot(currentNode)) {\n // Element is in shadow root\n currentNode = currentNode.host;\n } else {\n currentNode = currentNode.parentNode;\n }\n\n return currentNode;\n}\n\n/**\n * ShadowDOM safe version of element.parentElement.\n */\nexport function getParentElement(\n node: Node | null | undefined\n): Element | null {\n let parentNode = getParentNode(node);\n\n while (parentNode && !isElement(parentNode)) {\n parentNode = getParentNode(parentNode);\n }\n\n return parentNode;\n}\n\n/**\n * ShadowDOM safe version of Node.contains.\n */\nexport function nodeContains(\n node: EventTarget | null | undefined,\n otherNode: EventTarget | null | undefined\n): boolean {\n if (!isNode(node) || !isNode(otherNode)) {\n return false;\n }\n\n if (!shadowDOM()) {\n return node.contains(otherNode);\n }\n\n let currentNode: Node | null = otherNode;\n\n while (currentNode) {\n if (currentNode === node) {\n return true;\n }\n\n currentNode = getParentNode(currentNode);\n }\n\n return false;\n}\n\n/**\n * ShadowDOM safe version of document.activeElement.\n */\nexport const getActiveElement = (doc: Document = document): Element | null => {\n if (!shadowDOM()) {\n return doc.activeElement;\n }\n\n let activeElement: Element | null = doc.activeElement;\n\n while (\n activeElement &&\n \"shadowRoot\" in activeElement &&\n activeElement.shadowRoot?.activeElement\n ) {\n ({ activeElement } = activeElement.shadowRoot);\n }\n\n return activeElement;\n};\n\n// Possibly we can improve the types for this using https://github.com/adobe/react-spectrum/pull/8991/changes#diff-2d491c0c91701d28d08e1cf9fcadbdb21a030b67ab681460c9934140f29127b8R68 but it was more changes than I\n// wanted to make to fix the function.\n/**\n * ShadowDOM safe version of event.target.\n */\ntype ResolvedEventTarget<T> =\n unknown extends EventTargetType<T> ? EventTarget | null : EventTargetType<T>;\n\nexport function getEventTarget<T extends Event>(\n event: T\n): ResolvedEventTarget<T> {\n let { target } = event;\n\n if (\n shadowDOM() &&\n target instanceof Element &&\n target.shadowRoot &&\n \"composedPath\" in event\n ) {\n target = event.composedPath()[0] ?? null;\n }\n\n // SAFETY: This preserves the event's target contract after resolving its composed path; erased targets retain the native nullable EventTarget type.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- TypeScript cannot derive this conditional event-target type from the runtime path.\n return target as ResolvedEventTarget<T>;\n}\n\n/**\n * Returns the set of event targets a listener must be attached to in order to\n * globally observe an event.\n *\n * @param from - The target element to start from.\n * @param to - The element to stop at when bubbling. @default getOwnerWindow(from)\n * `to` is generally going to be either `document` or `window`, but\n * it can be any intermediate node.\n * @returns [global, ...shadowRoots]\n */\nexport function getPropagationTargets(\n from: Element | Document | Window | null | undefined,\n to?: Document | Window | Element | null\n): EventTarget[] {\n let currentTo = to;\n\n // If `to` is coming from a ref, its type technically allows `null`.\n // In practice, this function will generally be called from within an effect.\n // If the ref has not resolved by that point, then a coding error has been made.\n // Better to return an empty array than `[window]`, which may appear to work\n // in the light DOM, but fail in the shadow DOM.\n if (currentTo === null) {\n return [];\n }\n\n currentTo ??= getOwnerWindow(from);\n const targets: EventTarget[] = [currentTo];\n\n if (!shadowDOM() || !from || from === currentTo) {\n return targets;\n }\n\n // The root `to` itself lives in. The event already reaches `to` once\n // it is inside this root, so we must NOT collect this root or anything above\n // it — only the shadow roots strictly between `refNode` and `to`.\n // `window` has no getRootNode; its boundary is the document, which the walk\n // reaches naturally (the document is not a ShadowRoot, so the loop exits).\n const toRoot = \"getRootNode\" in currentTo ? currentTo.getRootNode() : null;\n let current: Node | null = \"getRootNode\" in from ? from.getRootNode() : null;\n\n while (isShadowRoot(current) && current !== toRoot) {\n // order shouldn't matter\n targets.push(current);\n current = current.host.getRootNode();\n }\n\n return targets;\n}\n\n/**\n * ShadowDOM safe fast version of node.contains(document.activeElement).\n *\n * @param node - The element whose subtree may contain focus.\n * @returns Whether the element contains the active element.\n */\nexport function isFocusWithin(node: Element | null | undefined): boolean {\n if (!node) {\n return false;\n }\n\n // Get the active element within the node's parent shadow root (or the document). Can return null.\n const root = node.getRootNode();\n const ownerWindow = getOwnerWindow(node);\n\n if (\n !(root instanceof ownerWindow.Document) &&\n !(root instanceof ownerWindow.ShadowRoot)\n ) {\n return false;\n }\n\n const { activeElement } = root;\n\n // Check if the active element is within this node. These nodes are within the same shadow root.\n return isPresent(activeElement) && node.contains(activeElement);\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAgB,cAAc,MAA4C;CACxE,IAAI,CAAC,UAAU,GACb,OAAO,MAAM,cAAc;CAG7B,IAAI,CAAC,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KAAK,CAAC,QAAQ,SAAS,WACpC,OAAO;CAQT,MAAM,SAAS,iBAAiB,YAAY,UAAU,YAAY,IAAI;CACtE,IAAI,UAAuB,iBAAiB,OAAO,KAAK,YAAY,IAAI;CAExE,OAAO,aAAa,OAAO,KAAK,YAAY,QAAQ;EAElD,QAAQ,KAAK,OAAO;EACpB,UAAU,QAAQ,KAAK,YAAY;CACrC;CAEA,OAAO;AACT;;;;;;;AAQA,SAAgB,cAAc,MAA2C;CACvE,IAAI,CAAC,MACH,OAAO;CAIT,MAAM,OAAO,KAAK,YAAY;CAC9B,MAAM,cAAc,eAAe,IAAI;CAEvC,IACE,EAAE,gBAAgB,YAAY,aAC9B,EAAE,gBAAgB,YAAY,aAE9B,OAAO;CAGT,MAAM,EAAE,kBAAkB;CAG1B,OAAO,UAAU,aAAa,KAAK,KAAK,SAAS,aAAa;AAChE"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
5
5
  */
6
6
  import { isTruthy } from "../truthy.js";
7
- import { isShadowRoot } from "../dom-helpers.js";
7
+ import { isShadowRoot } from "../type-helpers.js";
8
8
  import { nodeContains } from "./dom-functions.js";
9
9
  import { requireElement } from "../dom-value.js";
10
10
  import { shadowDOM } from "@solid2-aria/stately/flags/flags";
@@ -1 +1 @@
1
- {"version":3,"file":"shadow-tree-walker.js","names":[],"sources":["../../../../src/utils/shadowdom/shadow-tree-walker.ts"],"sourcesContent":["/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/utils/shadowdom/ShadowTreeWalker.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { shadowDOM } from \"@solid2-aria/stately/flags/flags\";\n\nimport { isShadowRoot } from \"../dom-helpers\";\nimport { requireElement } from \"../dom-value\";\nimport { isTruthy } from \"../truthy\";\n// https://github.com/microsoft/tabster/blob/a89fc5d7e332d48f68d03b1ca6e344489d1c3898/src/Shadowdomize/ShadowTreeWalker.ts\nimport { nodeContains } from \"./dom-functions\";\n\nexport class ShadowTreeWalker implements TreeWalker {\n public readonly filter: NodeFilter | null;\n public readonly root: Node;\n public readonly whatToShow: number;\n private readonly _doc: Document;\n private _walkerStack: TreeWalker[] = [];\n private _currentNode: Node;\n private readonly _currentSetFor = new Set<TreeWalker>();\n constructor(\n doc: Document,\n root: Node,\n whatToShow?: number,\n filter?: NodeFilter | null\n ) {\n this._doc = doc;\n this.root = root;\n this.filter = filter ?? null;\n this.whatToShow = whatToShow ?? NodeFilter.SHOW_ALL;\n this._currentNode = root;\n this._walkerStack.unshift(\n doc.createTreeWalker(root, whatToShow, this._acceptNode)\n );\n\n const shadowRoot =\n root.nodeType === Node.ELEMENT_NODE\n ? requireElement(root).shadowRoot\n : null;\n\n if (shadowRoot) {\n const walker = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {\n acceptNode: this._acceptNode,\n });\n\n this._walkerStack.unshift(walker);\n }\n }\n private readonly _acceptNode = (node: Node): number => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const { shadowRoot } = requireElement(node);\n\n if (shadowRoot) {\n const walker = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {\n acceptNode: this._acceptNode,\n });\n\n this._walkerStack.unshift(walker);\n\n return NodeFilter.FILTER_ACCEPT;\n }\n\n if (typeof this.filter === \"function\") {\n return this.filter(node);\n } else if (this.filter?.acceptNode) {\n return this.filter.acceptNode(node);\n } else if (this.filter === null) {\n return NodeFilter.FILTER_ACCEPT;\n }\n }\n\n return NodeFilter.FILTER_SKIP;\n };\n public get currentNode(): Node {\n return this._currentNode;\n }\n public set currentNode(node: Node) {\n if (!nodeContains(this.root, node)) {\n throw new Error(\n \"Cannot set currentNode to a node that is not contained by the root node.\"\n );\n }\n\n const walkers: TreeWalker[] = [];\n let curNode: Node | null | undefined = node;\n let currentWalkerCurrentNode = node;\n this._currentNode = node;\n\n while (curNode && curNode !== this.root) {\n if (isShadowRoot(curNode)) {\n const shadowRoot: ShadowRoot = curNode;\n\n const walker = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {\n acceptNode: this._acceptNode,\n });\n\n walkers.push(walker);\n walker.currentNode = currentWalkerCurrentNode;\n this._currentSetFor.add(walker);\n currentWalkerCurrentNode = shadowRoot.host;\n curNode = currentWalkerCurrentNode;\n } else {\n curNode = curNode.parentNode;\n }\n }\n\n const walker = this._doc.createTreeWalker(this.root, this.whatToShow, {\n acceptNode: this._acceptNode,\n });\n\n walkers.push(walker);\n walker.currentNode = currentWalkerCurrentNode;\n this._currentSetFor.add(walker);\n this._walkerStack = walkers;\n }\n public get doc(): Document {\n return this._doc;\n }\n public firstChild(): Node | null {\n const { currentNode } = this;\n const newNode = this.nextNode();\n\n if (!nodeContains(currentNode, newNode)) {\n this.currentNode = currentNode;\n\n return null;\n }\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n public lastChild(): Node | null {\n const [walker] = this._walkerStack;\n const newNode = walker?.lastChild() ?? null;\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n public nextNode(): Node | null {\n const nextNode = this._walkerStack[0]?.nextNode() ?? null;\n\n if (nextNode) {\n const { shadowRoot } = requireElement(nextNode);\n\n if (shadowRoot) {\n let nodeResult: number | undefined;\n\n if (typeof this.filter === \"function\") {\n nodeResult = this.filter(nextNode);\n } else if (this.filter?.acceptNode) {\n nodeResult = this.filter.acceptNode(nextNode);\n }\n\n if (nodeResult === NodeFilter.FILTER_ACCEPT) {\n this.currentNode = nextNode;\n\n return nextNode;\n }\n\n // _acceptNode should have added new walker for this shadow,\n // go in recursively.\n const newNode = this.nextNode();\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n\n if (isTruthy(nextNode)) {\n this.currentNode = nextNode;\n }\n\n return nextNode;\n }\n\n if (this._walkerStack.length > 1) {\n this._walkerStack.shift();\n const newNode = this.nextNode();\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n\n return null;\n }\n public previousNode(): Node | null {\n const [currentWalker] = this._walkerStack;\n\n if (!currentWalker) {\n return null;\n }\n\n if (currentWalker.currentNode === currentWalker.root) {\n if (this._currentSetFor.has(currentWalker)) {\n this._currentSetFor.delete(currentWalker);\n\n if (this._walkerStack.length > 1) {\n this._walkerStack.shift();\n const newNode = this.previousNode();\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n\n return null;\n }\n\n return null;\n }\n\n const previousNode = currentWalker.previousNode();\n\n if (previousNode) {\n const { shadowRoot } = requireElement(previousNode);\n\n if (shadowRoot) {\n let nodeResult: number | undefined;\n\n if (typeof this.filter === \"function\") {\n nodeResult = this.filter(previousNode);\n } else if (this.filter?.acceptNode) {\n nodeResult = this.filter.acceptNode(previousNode);\n }\n\n if (nodeResult === NodeFilter.FILTER_ACCEPT) {\n if (isTruthy(previousNode)) {\n this.currentNode = previousNode;\n }\n\n return previousNode;\n }\n\n // _acceptNode should have added new walker for this shadow,\n // go in recursively.\n const newNode = this.lastChild();\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n\n if (isTruthy(previousNode)) {\n this.currentNode = previousNode;\n }\n\n return previousNode;\n }\n\n if (this._walkerStack.length > 1) {\n this._walkerStack.shift();\n const newNode = this.previousNode();\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n\n return null;\n }\n /**\n * @deprecated\n */\n public nextSibling(): Node | null {\n // if (__DEV__) {\n // throw new Error(\"Method not implemented.\");\n // }\n return null;\n }\n /**\n * @deprecated\n */\n public previousSibling(): Node | null {\n // if (__DEV__) {\n // throw new Error(\"Method not implemented.\");\n // }\n return null;\n }\n /**\n * @deprecated\n */\n public parentNode(): Node | null {\n // if (__DEV__) {\n // throw new Error(\"Method not implemented.\");\n // }\n return null;\n }\n}\n\n/**\n * ShadowDOM safe version of document.createTreeWalker.\n */\nexport function createShadowTreeWalker(\n doc: Document,\n root: Node,\n whatToShow?: number,\n filter?: NodeFilter | null\n): TreeWalker {\n if (shadowDOM()) {\n return new ShadowTreeWalker(doc, root, whatToShow, filter);\n }\n\n return doc.createTreeWalker(root, whatToShow, filter);\n}\n"],"mappings":";;;;;;;;;;;AAcA,IAAa,mBAAb,MAAoD;CAClD;CACA;CACA;CACA;CACA,eAAqC,CAAC;CACtC;CACA,iCAAkC,IAAI,IAAgB;CACtD,YACE,KACA,MACA,YACA,QACA;EACA,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,SAAS,UAAU;EACxB,KAAK,aAAa,cAAc,WAAW;EAC3C,KAAK,eAAe;EACpB,KAAK,aAAa,QAChB,IAAI,iBAAiB,MAAM,YAAY,KAAK,WAAW,CACzD;EAEA,MAAM,aACJ,KAAK,aAAa,KAAK,eACnB,eAAe,IAAI,CAAC,CAAC,aACrB;EAEN,IAAI,YAAY;GACd,MAAM,SAAS,KAAK,KAAK,iBAAiB,YAAY,KAAK,YAAY,EACrE,YAAY,KAAK,YACnB,CAAC;GAED,KAAK,aAAa,QAAQ,MAAM;EAClC;CACF;CACA,eAAgC,SAAuB;EACrD,IAAI,KAAK,aAAa,KAAK,cAAc;GACvC,MAAM,EAAE,eAAe,eAAe,IAAI;GAE1C,IAAI,YAAY;IACd,MAAM,SAAS,KAAK,KAAK,iBAAiB,YAAY,KAAK,YAAY,EACrE,YAAY,KAAK,YACnB,CAAC;IAED,KAAK,aAAa,QAAQ,MAAM;IAEhC,OAAO,WAAW;GACpB;GAEA,IAAI,OAAO,KAAK,WAAW,YACzB,OAAO,KAAK,OAAO,IAAI;QAClB,IAAI,KAAK,QAAQ,YACtB,OAAO,KAAK,OAAO,WAAW,IAAI;QAC7B,IAAI,KAAK,WAAW,MACzB,OAAO,WAAW;EAEtB;EAEA,OAAO,WAAW;CACpB;CACA,IAAW,cAAoB;EAC7B,OAAO,KAAK;CACd;CACA,IAAW,YAAY,MAAY;E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rB,OAAO;EACT;EAEA,IAAI,KAAK,aAAa,SAAS,GAAG;GAChC,KAAK,aAAa,MAAM;GACxB,MAAM,UAAU,KAAK,aAAa;GAElC,IAAI,SACF,KAAK,cAAc;GAGrB,OAAO;EACT;EAEA,OAAO;CACT;;;;CAIA,cAAkC;EAIhC,OAAO;CACT;;;;CAIA,kBAAsC;EAIpC,OAAO;CACT;;;;CAIA,aAAiC;EAI/B,OAAO;CACT;AACF;;;;AAKA,SAAgB,uBACd,KACA,MACA,YACA,QACY;CACZ,IAAI,UAAU,GACZ,OAAO,IAAI,iBAAiB,KAAK,MAAM,YAAY,MAAM;CAG3D,OAAO,IAAI,iBAAiB,MAAM,YAAY,MAAM;AACtD"}
1
+ {"version":3,"file":"shadow-tree-walker.js","names":[],"sources":["../../../../src/utils/shadowdom/shadow-tree-walker.ts"],"sourcesContent":["/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/utils/shadowdom/ShadowTreeWalker.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { shadowDOM } from \"@solid2-aria/stately/flags/flags\";\n\nimport { requireElement } from \"../dom-value\";\nimport { isTruthy } from \"../truthy\";\nimport { isShadowRoot } from \"../type-helpers\";\n// https://github.com/microsoft/tabster/blob/a89fc5d7e332d48f68d03b1ca6e344489d1c3898/src/Shadowdomize/ShadowTreeWalker.ts\nimport { nodeContains } from \"./dom-functions\";\n\nexport class ShadowTreeWalker implements TreeWalker {\n public readonly filter: NodeFilter | null;\n public readonly root: Node;\n public readonly whatToShow: number;\n private readonly _doc: Document;\n private _walkerStack: TreeWalker[] = [];\n private _currentNode: Node;\n private readonly _currentSetFor = new Set<TreeWalker>();\n constructor(\n doc: Document,\n root: Node,\n whatToShow?: number,\n filter?: NodeFilter | null\n ) {\n this._doc = doc;\n this.root = root;\n this.filter = filter ?? null;\n this.whatToShow = whatToShow ?? NodeFilter.SHOW_ALL;\n this._currentNode = root;\n this._walkerStack.unshift(\n doc.createTreeWalker(root, whatToShow, this._acceptNode)\n );\n\n const shadowRoot =\n root.nodeType === Node.ELEMENT_NODE\n ? requireElement(root).shadowRoot\n : null;\n\n if (shadowRoot) {\n const walker = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {\n acceptNode: this._acceptNode,\n });\n\n this._walkerStack.unshift(walker);\n }\n }\n private readonly _acceptNode = (node: Node): number => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const { shadowRoot } = requireElement(node);\n\n if (shadowRoot) {\n const walker = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {\n acceptNode: this._acceptNode,\n });\n\n this._walkerStack.unshift(walker);\n\n return NodeFilter.FILTER_ACCEPT;\n }\n\n if (typeof this.filter === \"function\") {\n return this.filter(node);\n } else if (this.filter?.acceptNode) {\n return this.filter.acceptNode(node);\n } else if (this.filter === null) {\n return NodeFilter.FILTER_ACCEPT;\n }\n }\n\n return NodeFilter.FILTER_SKIP;\n };\n public get currentNode(): Node {\n return this._currentNode;\n }\n public set currentNode(node: Node) {\n if (!nodeContains(this.root, node)) {\n throw new Error(\n \"Cannot set currentNode to a node that is not contained by the root node.\"\n );\n }\n\n const walkers: TreeWalker[] = [];\n let curNode: Node | null | undefined = node;\n let currentWalkerCurrentNode = node;\n this._currentNode = node;\n\n while (curNode && curNode !== this.root) {\n if (isShadowRoot(curNode)) {\n const shadowRoot: ShadowRoot = curNode;\n\n const walker = this._doc.createTreeWalker(shadowRoot, this.whatToShow, {\n acceptNode: this._acceptNode,\n });\n\n walkers.push(walker);\n walker.currentNode = currentWalkerCurrentNode;\n this._currentSetFor.add(walker);\n currentWalkerCurrentNode = shadowRoot.host;\n curNode = currentWalkerCurrentNode;\n } else {\n curNode = curNode.parentNode;\n }\n }\n\n const walker = this._doc.createTreeWalker(this.root, this.whatToShow, {\n acceptNode: this._acceptNode,\n });\n\n walkers.push(walker);\n walker.currentNode = currentWalkerCurrentNode;\n this._currentSetFor.add(walker);\n this._walkerStack = walkers;\n }\n public get doc(): Document {\n return this._doc;\n }\n public firstChild(): Node | null {\n const { currentNode } = this;\n const newNode = this.nextNode();\n\n if (!nodeContains(currentNode, newNode)) {\n this.currentNode = currentNode;\n\n return null;\n }\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n public lastChild(): Node | null {\n const [walker] = this._walkerStack;\n const newNode = walker?.lastChild() ?? null;\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n public nextNode(): Node | null {\n const nextNode = this._walkerStack[0]?.nextNode() ?? null;\n\n if (nextNode) {\n const { shadowRoot } = requireElement(nextNode);\n\n if (shadowRoot) {\n let nodeResult: number | undefined;\n\n if (typeof this.filter === \"function\") {\n nodeResult = this.filter(nextNode);\n } else if (this.filter?.acceptNode) {\n nodeResult = this.filter.acceptNode(nextNode);\n }\n\n if (nodeResult === NodeFilter.FILTER_ACCEPT) {\n this.currentNode = nextNode;\n\n return nextNode;\n }\n\n // _acceptNode should have added new walker for this shadow,\n // go in recursively.\n const newNode = this.nextNode();\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n\n if (isTruthy(nextNode)) {\n this.currentNode = nextNode;\n }\n\n return nextNode;\n }\n\n if (this._walkerStack.length > 1) {\n this._walkerStack.shift();\n const newNode = this.nextNode();\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n\n return null;\n }\n public previousNode(): Node | null {\n const [currentWalker] = this._walkerStack;\n\n if (!currentWalker) {\n return null;\n }\n\n if (currentWalker.currentNode === currentWalker.root) {\n if (this._currentSetFor.has(currentWalker)) {\n this._currentSetFor.delete(currentWalker);\n\n if (this._walkerStack.length > 1) {\n this._walkerStack.shift();\n const newNode = this.previousNode();\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n\n return null;\n }\n\n return null;\n }\n\n const previousNode = currentWalker.previousNode();\n\n if (previousNode) {\n const { shadowRoot } = requireElement(previousNode);\n\n if (shadowRoot) {\n let nodeResult: number | undefined;\n\n if (typeof this.filter === \"function\") {\n nodeResult = this.filter(previousNode);\n } else if (this.filter?.acceptNode) {\n nodeResult = this.filter.acceptNode(previousNode);\n }\n\n if (nodeResult === NodeFilter.FILTER_ACCEPT) {\n if (isTruthy(previousNode)) {\n this.currentNode = previousNode;\n }\n\n return previousNode;\n }\n\n // _acceptNode should have added new walker for this shadow,\n // go in recursively.\n const newNode = this.lastChild();\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n\n if (isTruthy(previousNode)) {\n this.currentNode = previousNode;\n }\n\n return previousNode;\n }\n\n if (this._walkerStack.length > 1) {\n this._walkerStack.shift();\n const newNode = this.previousNode();\n\n if (newNode) {\n this.currentNode = newNode;\n }\n\n return newNode;\n }\n\n return null;\n }\n /**\n * @deprecated\n */\n public nextSibling(): Node | null {\n // if (__DEV__) {\n // throw new Error(\"Method not implemented.\");\n // }\n return null;\n }\n /**\n * @deprecated\n */\n public previousSibling(): Node | null {\n // if (__DEV__) {\n // throw new Error(\"Method not implemented.\");\n // }\n return null;\n }\n /**\n * @deprecated\n */\n public parentNode(): Node | null {\n // if (__DEV__) {\n // throw new Error(\"Method not implemented.\");\n // }\n return null;\n }\n}\n\n/**\n * ShadowDOM safe version of document.createTreeWalker.\n */\nexport function createShadowTreeWalker(\n doc: Document,\n root: Node,\n whatToShow?: number,\n filter?: NodeFilter | null\n): TreeWalker {\n if (shadowDOM()) {\n return new ShadowTreeWalker(doc, root, whatToShow, filter);\n }\n\n return doc.createTreeWalker(root, whatToShow, filter);\n}\n"],"mappings":";;;;;;;;;;;AAcA,IAAa,mBAAb,MAAoD;CAClD;CACA;CACA;CACA;CACA,eAAqC,CAAC;CACtC;CACA,iCAAkC,IAAI,IAAgB;CACtD,YACE,KACA,MACA,YACA,QACA;EACA,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,SAAS,UAAU;EACxB,KAA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3D,OAAO,IAAI,iBAAiB,MAAM,YAAY,MAAM;AACtD"}
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ /*
13
+ * Derived from Adobe React Spectrum: packages/react-aria/src/utils/typeHelpers.ts.
14
+ * Modified for Solid Aria: adapted type guard narrowing and formatting for Solid 2.
15
+ * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
16
+ */
17
+ /**
18
+ * Type guard that checks if a value is a Node. Verifies the presence and type of the nodeType
19
+ * property.
20
+ */
21
+ export declare function isNode<T>(value: T): value is T & Node;
22
+ /**
23
+ * Type guard that checks if a value is a Window. Uses window self reference checks to
24
+ * distinguish Window from other values.
25
+ */
26
+ export declare function isWindow<T>(value: T): value is T & Window & typeof globalThis;
27
+ /**
28
+ * Type guard that checks if a value is a Document. Uses nodeType and host property checks to
29
+ * distinguish Document from other values.
30
+ */
31
+ export declare function isDocument<T>(value: T): value is T & Document;
32
+ /**
33
+ * Type guard that checks if a value is a ShadowRoot. Uses nodeType and host property checks to
34
+ * distinguish ShadowRoot from other values.
35
+ */
36
+ export declare function isShadowRoot<T>(value: T): value is T & ShadowRoot;
37
+ /**
38
+ * Type guard that checks if a value is an Element. Uses nodeType checks to distinguish Element
39
+ * from other values.
40
+ */
41
+ export declare function isElement(value: unknown): value is Element;
42
+ //# sourceMappingURL=type-helpers.d.ts.map
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ /*
13
+ * Derived from Adobe React Spectrum: packages/react-aria/src/utils/typeHelpers.ts.
14
+ * Modified for Solid Aria: adapted type guard narrowing and formatting for Solid 2.
15
+ * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
16
+ */
17
+ // src/utils/type-helpers.ts
18
+ /**
19
+ * Type guard that checks if a value is a Node. Verifies the presence and type of the nodeType
20
+ * property.
21
+ */
22
+ function isNode(value) {
23
+ return value !== null && typeof value === "object" && "nodeType" in value && typeof value.nodeType === "number";
24
+ }
25
+ /**
26
+ * Type guard that checks if a value is a Window. Uses window self reference checks to
27
+ * distinguish Window from other values.
28
+ */
29
+ function isWindow(value) {
30
+ return typeof value === "object" && value !== null && value !== void 0 && "window" in value && value.window === value;
31
+ }
32
+ /**
33
+ * Type guard that checks if a value is a Document. Uses nodeType and host property checks to
34
+ * distinguish Document from other values.
35
+ */
36
+ function isDocument(value) {
37
+ return isNode(value) && value.nodeType === 9;
38
+ }
39
+ /**
40
+ * Type guard that checks if a value is a ShadowRoot. Uses nodeType and host property checks to
41
+ * distinguish ShadowRoot from other values.
42
+ */
43
+ function isShadowRoot(value) {
44
+ return isNode(value) && value.nodeType === 11 && "host" in value;
45
+ }
46
+ /**
47
+ * Type guard that checks if a value is an Element. Uses nodeType checks to distinguish Element
48
+ * from other values.
49
+ */
50
+ function isElement(value) {
51
+ return isNode(value) && value.nodeType === 1;
52
+ }
53
+ export { isDocument, isElement, isNode, isShadowRoot, isWindow };
54
+
55
+ //# sourceMappingURL=type-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-helpers.js","names":[],"sources":["../../../src/utils/type-helpers.ts"],"sourcesContent":["/*\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/utils/typeHelpers.ts.\n * Modified for Solid Aria: adapted type guard narrowing and formatting for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\n/**\n * Type guard that checks if a value is a Node. Verifies the presence and type of the nodeType\n * property.\n */\nexport function isNode<T>(value: T): value is T & Node {\n return (\n value !== null &&\n typeof value === \"object\" &&\n \"nodeType\" in value &&\n typeof value.nodeType === \"number\"\n );\n}\n\n/**\n * Type guard that checks if a value is a Window. Uses window self reference checks to\n * distinguish Window from other values.\n */\nexport function isWindow<T>(value: T): value is T & Window & typeof globalThis {\n return (\n typeof value === \"object\" &&\n value !== null &&\n value !== undefined &&\n \"window\" in value &&\n value.window === value\n );\n}\n\n/**\n * Type guard that checks if a value is a Document. Uses nodeType and host property checks to\n * distinguish Document from other values.\n */\nexport function isDocument<T>(value: T): value is T & Document {\n return isNode(value) && value.nodeType === 9;\n}\n\n/**\n * Type guard that checks if a value is a ShadowRoot. Uses nodeType and host property checks to\n * distinguish ShadowRoot from other values.\n */\nexport function isShadowRoot<T>(value: T): value is T & ShadowRoot {\n // 11 = DOCUMENT_FRAGMENT_NODE\n return isNode(value) && value.nodeType === 11 && \"host\" in value;\n}\n\n/**\n * Type guard that checks if a value is an Element. Uses nodeType checks to distinguish Element\n * from other values.\n */\nexport function isElement(value: unknown): value is Element {\n // 1 = ELEMENT_NODE\n return isNode(value) && value.nodeType === 1;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,OAAU,OAA6B;CACrD,OACE,UAAU,QACV,OAAO,UAAU,YACjB,cAAc,SACd,OAAO,MAAM,aAAa;AAE9B;;;;;AAMA,SAAgB,SAAY,OAAmD;CAC7E,OACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,KAAA,KACV,YAAY,SACZ,MAAM,WAAW;AAErB;;;;;AAMA,SAAgB,WAAc,OAAiC;CAC7D,OAAO,OAAO,KAAK,KAAK,MAAM,aAAa;AAC7C;;;;;AAMA,SAAgB,aAAgB,OAAmC;CAEjE,OAAO,OAAO,KAAK,KAAK,MAAM,aAAa,MAAM,UAAU;AAC7D;;;;;AAMA,SAAgB,UAAU,OAAkC;CAE1D,OAAO,OAAO,KAAK,KAAK,MAAM,aAAa;AAC7C"}
@@ -15,6 +15,7 @@
15
15
  * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.
16
16
  */
17
17
  import { getTruthyValue } from "../utils/truthy.js";
18
+ import { getParentElement } from "../utils/shadowdom/dom-functions.js";
18
19
  import { createKeyboard } from "../interactions/create-keyboard.js";
19
20
  import { createLocale } from "../i18n/i18n-provider.js";
20
21
  import { ariaValue } from "../utils/aria-value.js";
@@ -31,7 +32,7 @@ function createActionGroup(props, state, ref) {
31
32
  const [isInToolbar, setInToolbar] = createSignal(false, { ownedWrite: true });
32
33
  createEffect(() => ({ element: ref() }), ({ element }) => {
33
34
  const refElement = element;
34
- setInToolbar(!!(refElement && refElement.parentElement?.closest("[role=\"toolbar\"]")));
35
+ setInToolbar(!!(refElement && getParentElement(refElement)?.closest("[role=\"toolbar\"]")));
35
36
  }, { ssrSource: "client" });
36
37
  const isDisabled = createMemo(() => getTruthyValue(props.isDisabled) ?? ![...state.collection.getKeys()].some((key) => !state.disabledKeys.has(key)));
37
38
  const _result0 = createLocale();
@@ -1 +1 @@
1
- {"version":3,"file":"create-action-group.js","names":[],"sources":["../../../src/actiongroup/create-action-group.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/actiongroup/useActionGroup.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport type { ListState } from \"@solid2-aria/stately/list/create-list-state\";\nimport type {\n AriaLabelingProps,\n DOMProps,\n FocusableElement,\n ItemElement,\n ItemRenderer,\n Key,\n MultipleSelection,\n Orientation,\n} from \"@solid2-aria/types-shared\";\nimport type { DOMAttributes } from \"@solid2-aria/types-shared-web\";\nimport { merge, omit, createMemo, createSignal, createEffect } from \"solid-js\";\nimport type { Accessor } from \"solid-js\";\n\nimport { createFocusManager } from \"../focus/focus-scope\";\nimport { createLocale } from \"../i18n/i18n-provider\";\nimport { createKeyboard } from \"../interactions/create-keyboard\";\nimport { ariaValue } from \"../utils/aria-value\";\nimport { filterDOMProps } from \"../utils/filter-dom-props\";\nimport { getTruthyValue } from \"../utils/truthy\";\n\nconst BUTTON_GROUP_ROLES = {\n multiple: \"toolbar\",\n none: \"toolbar\",\n single: \"radiogroup\",\n} as const;\n\n// Not extending CollectionBase to avoid async loading props\nexport interface ActionGroupProps<T> extends MultipleSelection {\n /**\n * The axis the ActionGroup should align with.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation;\n /**\n * An list of `Item` elements or a function. If the latter, a list of items must be provided using\n * the `items` prop.\n */\n children: ItemElement<T> | ItemElement<T>[] | ItemRenderer<T>;\n /** A list of items to display as children. Must be used with a function as the sole child. */\n items?: Iterable<T>;\n /** A list of keys to disable. */\n disabledKeys?: Iterable<Key>;\n /**\n * Whether the ActionGroup is disabled.\n * Shows that a selection exists, but is not available in that circumstance.\n */\n isDisabled?: boolean;\n /**\n * Invoked when an action is taken on a child. Especially useful when `selectionMode` is none.\n * The sole argument `key` is the key for the item.\n */\n onAction?: (key: Key) => void;\n}\n\nexport interface AriaActionGroupProps<T>\n extends ActionGroupProps<T>, DOMProps, AriaLabelingProps {}\n\nexport interface ActionGroupAria {\n actionGroupProps: DOMAttributes;\n}\n\nexport function createActionGroup<T>(\n props: AriaActionGroupProps<T>,\n state: ListState<T>,\n ref: Accessor<FocusableElement | null>\n): ActionGroupAria {\n const [isInToolbar, setInToolbar] = createSignal(false, { ownedWrite: true });\n createEffect(\n () => ({ element: ref() }),\n ({ element }) => {\n const refElement = element;\n setInToolbar(\n !!(refElement && refElement.parentElement?.closest('[role=\"toolbar\"]'))\n );\n },\n { ssrSource: \"client\" }\n );\n\n const isDisabled = createMemo(\n () =>\n getTruthyValue(props.isDisabled) ??\n ![...state.collection.getKeys()].some(\n (key) => !state.disabledKeys.has(key)\n )\n );\n\n const _result0 = createLocale();\n\n const focusManager = createFocusManager(ref);\n // ArrowLeft/ArrowRight follow the locale's text direction regardless of orientation, so\n // ArrowLeft always moves to the next item in RTL. ArrowUp/ArrowDown are never flipped.\n const flipDirection = createMemo(() => _result0.direction === \"rtl\");\n\n const _result1 = createKeyboard({\n get allowRepeats(): true {\n return true;\n },\n get shortcuts() {\n return {\n ArrowDown: () => {\n focusManager.focusNext({ wrap: true });\n },\n ArrowLeft: () => {\n if (flipDirection()) {\n focusManager.focusNext({ wrap: true });\n } else {\n focusManager.focusPrevious({ wrap: true });\n }\n },\n ArrowRight: () => {\n if (flipDirection()) {\n focusManager.focusPrevious({ wrap: true });\n } else {\n focusManager.focusNext({ wrap: true });\n }\n },\n ArrowUp: () => {\n focusManager.focusPrevious({ wrap: true });\n },\n };\n },\n });\n\n const role = createMemo(() => {\n const value = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n\n return isInToolbar() && value === \"toolbar\" ? (\"group\" as const) : value;\n });\n\n return {\n get actionGroupProps() {\n return merge(\n filterDOMProps(props, { labelable: true }),\n omit(_result1.keyboardProps, \"role\"),\n {\n get \"aria-disabled\"() {\n return ariaValue(isDisabled());\n },\n get \"aria-orientation\"() {\n return role() === \"toolbar\"\n ? (props.orientation ?? \"horizontal\")\n : undefined;\n },\n get role() {\n return role();\n },\n }\n );\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,qBAAqB;CACzB,UAAU;CACV,MAAM;CACN,QAAQ;AACV;AAsCA,SAAgB,kBACd,OACA,OACA,KACiB;CACjB,MAAM,CAAC,aAAa,gBAAgB,aAAa,OAAO,EAAE,YAAY,KAAK,CAAC;CAC5E,oBACS,EAAE,SAAS,IAAI,EAAE,KACvB,EAAE,cAAc;EACf,MAAM,aAAa;EACnB,aACE,CAAC,EAAE,cAAc,WAAW,eAAe,QAAQ,oBAAkB,EACvE;CACF,GACA,EAAE,WAAW,SAAS,CACxB;CAEA,MAAM,aAAa,iBAEf,eAAe,MAAM,UAAU,KAC/B,CAAC,CAAC,GAAG,MAAM,WAAW,QAAQ,CAAC,CAAC,CAAC,MAC9B,QAAQ,CAAC,MAAM,aAAa,IAAI,GAAG,CACtC,CACJ;CAEA,MAAM,WAAW,aAAa;CAE9B,MAAM,eAAe,mBAAmB,GAAG;CAG3C,MAAM,gBAAgB,iBAAiB,SAAS,cAAc,KAAK;CAEnE,MAAM,WAAW,eAAe;EAC9B,IAAI,eAAqB;GACvB,OAAO;EACT;EACA,IAAI,YAAY;GACd,OAAO;IACL,iBAAiB;KACf,aAAa,UAAU,EAAE,MAAM,KAAK,CAAC;IACvC;IACA,iBAAiB;KACf,IAAI,cAAc,GAChB,aAAa,UAAU,EAAE,MAAM,KAAK,CAAC;UAErC,aAAa,cAAc,EAAE,MAAM,KAAK,CAAC;IAE7C;IACA,kBAAkB;KAChB,IAAI,cAAc,GAChB,aAAa,cAAc,EAAE,MAAM,KAAK,CAAC;UAEzC,aAAa,UAAU,EAAE,MAAM,KAAK,CAAC;IAEzC;IACA,eAAe;KACb,aAAa,cAAc,EAAE,MAAM,KAAK,CAAC;IAC3C;GACF;EACF;CACF,CAAC;CAED,MAAM,OAAO,iBAAiB;EAC5B,MAAM,QAAQ,mBAAmB,MAAM,iBAAiB;EAExD,OAAO,YAAY,KAAK,UAAU,YAAa,UAAoB;CACrE,CAAC;CAED,OAAO,EACL,IAAI,mBAAmB;EACrB,OAAO,MACL,eAAe,OAAO,EAAE,WAAW,KAAK,CAAC,GACzC,KAAK,SAAS,eAAe,MAAM,GACnC;GACE,IAAI,kBAAkB;IACpB,OAAO,UAAU,WAAW,CAAC;GAC/B;GACA,IAAI,qBAAqB;IACvB,OAAO,KAAK,MAAM,YACb,MAAM,eAAe,eACtB,KAAA;GACN;GACA,IAAI,OAAO;IACT,OAAO,KAAK;GACd;EACF,CACF;CACF,EACF;AACF"}
1
+ {"version":3,"file":"create-action-group.js","names":[],"sources":["../../../src/actiongroup/create-action-group.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/*\n * Derived from Adobe React Spectrum: packages/react-aria/src/actiongroup/useActionGroup.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport type { ListState } from \"@solid2-aria/stately/list/create-list-state\";\nimport type {\n AriaLabelingProps,\n DOMProps,\n FocusableElement,\n ItemElement,\n ItemRenderer,\n Key,\n MultipleSelection,\n Orientation,\n} from \"@solid2-aria/types-shared\";\nimport type { DOMAttributes } from \"@solid2-aria/types-shared-web\";\nimport { merge, omit, createMemo, createSignal, createEffect } from \"solid-js\";\nimport type { Accessor } from \"solid-js\";\n\nimport { createFocusManager } from \"../focus/focus-scope\";\nimport { createLocale } from \"../i18n/i18n-provider\";\nimport { createKeyboard } from \"../interactions/create-keyboard\";\nimport { ariaValue } from \"../utils/aria-value\";\nimport { filterDOMProps } from \"../utils/filter-dom-props\";\nimport { getParentElement } from \"../utils/shadowdom/dom-functions\";\nimport { getTruthyValue } from \"../utils/truthy\";\n\nconst BUTTON_GROUP_ROLES = {\n multiple: \"toolbar\",\n none: \"toolbar\",\n single: \"radiogroup\",\n} as const;\n\n// Not extending CollectionBase to avoid async loading props\nexport interface ActionGroupProps<T> extends MultipleSelection {\n /**\n * The axis the ActionGroup should align with.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation;\n /**\n * An list of `Item` elements or a function. If the latter, a list of items must be provided using\n * the `items` prop.\n */\n children: ItemElement<T> | ItemElement<T>[] | ItemRenderer<T>;\n /** A list of items to display as children. Must be used with a function as the sole child. */\n items?: Iterable<T>;\n /** A list of keys to disable. */\n disabledKeys?: Iterable<Key>;\n /**\n * Whether the ActionGroup is disabled.\n * Shows that a selection exists, but is not available in that circumstance.\n */\n isDisabled?: boolean;\n /**\n * Invoked when an action is taken on a child. Especially useful when `selectionMode` is none.\n * The sole argument `key` is the key for the item.\n */\n onAction?: (key: Key) => void;\n}\n\nexport interface AriaActionGroupProps<T>\n extends ActionGroupProps<T>, DOMProps, AriaLabelingProps {}\n\nexport interface ActionGroupAria {\n actionGroupProps: DOMAttributes;\n}\n\nexport function createActionGroup<T>(\n props: AriaActionGroupProps<T>,\n state: ListState<T>,\n ref: Accessor<FocusableElement | null>\n): ActionGroupAria {\n const [isInToolbar, setInToolbar] = createSignal(false, { ownedWrite: true });\n createEffect(\n () => ({ element: ref() }),\n ({ element }) => {\n const refElement = element;\n setInToolbar(\n !!(\n refElement &&\n getParentElement(refElement)?.closest('[role=\"toolbar\"]')\n )\n );\n },\n { ssrSource: \"client\" }\n );\n\n const isDisabled = createMemo(\n () =>\n getTruthyValue(props.isDisabled) ??\n ![...state.collection.getKeys()].some(\n (key) => !state.disabledKeys.has(key)\n )\n );\n\n const _result0 = createLocale();\n\n const focusManager = createFocusManager(ref);\n // ArrowLeft/ArrowRight follow the locale's text direction regardless of orientation, so\n // ArrowLeft always moves to the next item in RTL. ArrowUp/ArrowDown are never flipped.\n const flipDirection = createMemo(() => _result0.direction === \"rtl\");\n\n const _result1 = createKeyboard({\n get allowRepeats(): true {\n return true;\n },\n get shortcuts() {\n return {\n ArrowDown: () => {\n focusManager.focusNext({ wrap: true });\n },\n ArrowLeft: () => {\n if (flipDirection()) {\n focusManager.focusNext({ wrap: true });\n } else {\n focusManager.focusPrevious({ wrap: true });\n }\n },\n ArrowRight: () => {\n if (flipDirection()) {\n focusManager.focusPrevious({ wrap: true });\n } else {\n focusManager.focusNext({ wrap: true });\n }\n },\n ArrowUp: () => {\n focusManager.focusPrevious({ wrap: true });\n },\n };\n },\n });\n\n const role = createMemo(() => {\n const value = BUTTON_GROUP_ROLES[state.selectionManager.selectionMode];\n\n return isInToolbar() && value === \"toolbar\" ? (\"group\" as const) : value;\n });\n\n return {\n get actionGroupProps() {\n return merge(\n filterDOMProps(props, { labelable: true }),\n omit(_result1.keyboardProps, \"role\"),\n {\n get \"aria-disabled\"() {\n return ariaValue(isDisabled());\n },\n get \"aria-orientation\"() {\n return role() === \"toolbar\"\n ? (props.orientation ?? \"horizontal\")\n : undefined;\n },\n get role() {\n return role();\n },\n }\n );\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwC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mBAAmB;EACrB,OAAO,MACL,eAAe,OAAO,EAAE,WAAW,KAAK,CAAC,GACzC,KAAK,SAAS,eAAe,MAAM,GACnC;GACE,IAAI,kBAAkB;IACpB,OAAO,UAAU,WAAW,CAAC;GAC/B;GACA,IAAI,qBAAqB;IACvB,OAAO,KAAK,MAAM,YACb,MAAM,eAAe,eACtB,KAAA;GACN;GACA,IAAI,OAAO;IACT,OAAO,KAAK;GACd;EACF,CACF;CACF,EACF;AACF"}
@@ -27,7 +27,7 @@ import { isAppleDevice } from "../utils/platform.js";
27
27
  import { createKeyboard } from "../interactions/create-keyboard.js";
28
28
  import { createRouter } from "../utils/open-link.js";
29
29
  import { setInteractionModality } from "../interactions/create-focus-visible.js";
30
- import { dispatchVirtualFocus } from "../focus/virtual-focus.js";
30
+ import { dispatchVirtualFocus, getOriginalRelatedTarget } from "../focus/virtual-focus.js";
31
31
  import { createLocalizedStringFormatter } from "../i18n/create-localized-string-formatter.js";
32
32
  import { ariaValue } from "../utils/aria-value.js";
33
33
  import { createEvent } from "../utils/create-event.js";
@@ -181,7 +181,7 @@ function createComboBox(props, state) {
181
181
  });
182
182
  const onBlur = (e) => {
183
183
  const blurFromButton = nodeContains(buttonRef(), elementOrNull(e.relatedTarget));
184
- const blurIntoPopover = nodeContains(props.popoverRef(), e.relatedTarget instanceof Node ? e.relatedTarget : null);
184
+ const blurIntoPopover = nodeContains(props.popoverRef(), getOriginalRelatedTarget(e));
185
185
  if (blurFromButton || blurIntoPopover) return;
186
186
  if (props.onBlur) props.onBlur(e);
187
187
  state.setFocused(false);