@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":"create-combo-box.js","names":["intlMessages"],"sources":["../../../src/combobox/create-combo-box.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/combobox/useComboBox.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2; compute localized announcements in tracking scopes before publishing them from effects.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { getChildNodes } from \"@solid2-aria/stately/collections/get-child-nodes\";\nimport { getItemCount } from \"@solid2-aria/stately/collections/get-item-count\";\nimport type {\n ComboBoxProps,\n ComboBoxState,\n} from \"@solid2-aria/stately/combobox/create-combo-box-state\";\nimport { privateValidationStateProp } from \"@solid2-aria/stately/form/create-form-validation-state\";\nimport type { SelectionMode } from \"@solid2-aria/stately/select/create-select-state\";\nimport type {\n KeyboardEvent,\n AriaLabelingProps,\n DOMProps,\n InputDOMProps,\n KeyboardDelegate,\n LayoutDelegate,\n PressEvent,\n ValidationResult,\n} from \"@solid2-aria/types-shared\";\nimport type { DOMAttributes } from \"@solid2-aria/types-shared-web\";\nimport { merge, omit, createEffect, createMemo, untrack } from \"solid-js\";\nimport type { Accessor } from \"solid-js\";\n\nimport intlMessages from \"../../intl/combobox/index\";\nimport type { AriaButtonProps } from \"../button/create-button\";\nimport { dispatchVirtualFocus } from \"../focus/virtual-focus\";\nimport { createLocalizedStringFormatter } from \"../i18n/create-localized-string-formatter\";\nimport { setInteractionModality } from \"../interactions/create-focus-visible\";\nimport { createKeyboard } from \"../interactions/create-keyboard\";\nimport type { FieldAria } from \"../label/create-field\";\nimport type { AriaListBoxOptions } from \"../listbox/create-list-box\";\nimport { getItemId, listData } from \"../listbox/utils\";\nimport { announce } from \"../live-announcer/live-announcer\";\nimport { createMenuTrigger } from \"../menu/create-menu-trigger\";\nimport { ariaHideOutside } from \"../overlays/aria-hide-outside\";\nimport { createSelectableCollection } from \"../selection/create-selectable-collection\";\nimport { ListKeyboardDelegate } from \"../selection/list-keyboard-delegate\";\nimport { createTextField } from \"../textfield/create-text-field\";\nimport type {\n ElementType,\n FocusEvent,\n InputHTMLAttributes,\n TouchEvent,\n} from \"../types\";\nimport { ariaValue } from \"../utils/aria-value\";\nimport { chain } from \"../utils/chain\";\nimport { createEvent } from \"../utils/create-event\";\nimport { createFormReset } from \"../utils/create-form-reset\";\nimport { createSlotId } from \"../utils/create-id\";\nimport { createLabels } from \"../utils/create-labels\";\nimport { getOwnerDocument } from \"../utils/dom-helpers\";\nimport { elementOrNull } from \"../utils/dom-value\";\nimport { getCollectionNodeProps } from \"../utils/get-collection-node-props\";\nimport { isPresent } from \"../utils/is-present\";\nimport { getLegacyOption } from \"../utils/legacy-option\";\nimport { mergeProps } from \"../utils/merge-props\";\nimport { createRouter } from \"../utils/open-link\";\nimport { isAppleDevice } from \"../utils/platform\";\nimport { requireValue } from \"../utils/require-value\";\nimport {\n getActiveElement,\n getEventTarget,\n nodeContains,\n} from \"../utils/shadowdom/dom-functions\";\nimport { getTruthyValue, isTruthy, whenTruthy } from \"../utils/truthy\";\n\nexport interface AriaComboBoxProps<T, M extends SelectionMode = \"single\">\n extends ComboBoxProps<T, M>, DOMProps, InputDOMProps, AriaLabelingProps {\n /** Whether keyboard navigation is circular. */\n shouldFocusWrap?: boolean;\n}\n\nexport interface AriaComboBoxOptions<\n T,\n M extends SelectionMode = \"single\",\n> extends Omit<AriaComboBoxProps<T, M>, \"children\"> {\n /** The ref for the input element. */\n inputRef: Accessor<HTMLInputElement | null>;\n /** The ref for the list box popover. */\n popoverRef: Accessor<Element | null>;\n /** The ref for the list box. */\n listBoxRef: Accessor<HTMLElement | null>;\n /** The ref for the optional list box popup trigger button. */\n buttonRef?: Accessor<Element | null>;\n /**\n * The HTML element used to render the label, e.g. 'label', or 'span'.\n *\n * @default 'label'\n */\n labelElementType?: ElementType;\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n}\n\nexport interface ComboBoxAria<T> extends ValidationResult {\n /** Props for the label element. */\n labelProps: FieldAria[\"labelProps\"];\n /** Props for the combo box input element. */\n inputProps: InputHTMLAttributes;\n /** Props for the list box, to be passed to `useListBox`. */\n listBoxProps: AriaListBoxOptions<T>;\n /** Props for the optional trigger button, to be passed to `useButton`. */\n buttonProps: AriaButtonProps;\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n /** Props for the combo box description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the combo box error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a combo box component. A combo box\n * combines a text input with a listbox, allowing users to filter a list of options to items\n * matching a query.\n *\n * @param props - Props for the combo box.\n * @param state - State for the select, as returned by `useComboBoxState`.\n */\nexport function createComboBox<T, M extends SelectionMode = \"single\">(\n props: AriaComboBoxOptions<T, M>,\n state: ComboBoxState<T, M>\n): ComboBoxAria<T> {\n const buttonRef = props.buttonRef ?? (() => null);\n\n const stringFormatter = createLocalizedStringFormatter(\n intlMessages,\n \"@react-aria/combobox\"\n );\n\n const _result0 = createMenuTrigger<T>(\n {\n get isDisabled() {\n return getTruthyValue(props.isDisabled) ?? props.isReadOnly;\n },\n get type(): \"listbox\" {\n return \"listbox\";\n },\n },\n state,\n buttonRef\n );\n\n // Set listbox id so it can be used when calling getItemId later\n listData.set(state, {\n get id() {\n return _result0.menuProps.id;\n },\n });\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n const _result1 = state;\n const _result2 = untrack(() => state.selectionManager);\n\n const delegate = createMemo(\n () =>\n getTruthyValue(props.keyboardDelegate) ??\n new ListKeyboardDelegate({\n collection: _result1.collection,\n disabledKeys: _result2.disabledKeys,\n layoutDelegate: props.layoutDelegate,\n ref: props.listBoxRef,\n })\n );\n\n // Use useSelectableCollection to get the keyboard handlers to apply to the textfield\n const _result3 = createSelectableCollection({\n get disallowEmptySelection(): true {\n return true;\n },\n get disallowTypeAhead(): true {\n return true;\n },\n // Prevent item scroll behavior from being applied here, should be handled in the user's Popover + ListBox component\n get isVirtualized(): true {\n return true;\n },\n get keyboardDelegate() {\n return delegate();\n },\n get ref() {\n return props.inputRef;\n },\n get selectionManager() {\n return state.selectionManager;\n },\n get shouldFocusWrap() {\n return props.shouldFocusWrap;\n },\n });\n\n const router = createRouter();\n\n // for textfield specific operations\n const _result4 = createKeyboard({\n get shortcuts() {\n return {\n Enter: (e: KeyboardEvent) => {\n const propslistBoxRefElement = props.listBoxRef();\n // Prevent default form submission if menu is open since we may be selecting a option\n const shouldPreventDefault = state.isOpen;\n\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (\n state.isOpen &&\n propslistBoxRefElement &&\n state.selectionManager.focusedKey !== null &&\n state.selectionManager.focusedKey !== undefined\n ) {\n const collectionItem = state.collection.getItem(\n state.selectionManager.focusedKey\n );\n\n const collectionItemBehavior =\n getCollectionNodeProps(collectionItem);\n\n if (\n collectionItem !== null &&\n isTruthy(collectionItemBehavior.href)\n ) {\n const item = propslistBoxRefElement.querySelector(\n `[data-key=\"${CSS.escape(state.selectionManager.focusedKey.toString())}\"]`\n );\n\n if (item instanceof HTMLAnchorElement) {\n router.open(\n item,\n e,\n collectionItemBehavior.href,\n collectionItemBehavior.routerOptions\n );\n }\n\n state.close();\n\n return { shouldPreventDefault };\n } else if (\n collectionItem !== null &&\n isTruthy(collectionItemBehavior.onAction)\n ) {\n collectionItemBehavior.onAction();\n state.close();\n\n return { shouldPreventDefault };\n }\n }\n\n state.commit();\n\n return { shouldPreventDefault };\n },\n Escape: () => {\n let shouldContinuePropagation = false;\n\n if (\n !state.selectionManager.isEmpty ||\n state.inputValue === \"\" ||\n isTruthy(props.allowsCustomValue)\n ) {\n shouldContinuePropagation = true;\n }\n\n state.revert();\n\n return { shouldContinuePropagation };\n },\n Tab: () => {\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (\n state.isOpen &&\n props.listBoxRef() &&\n state.selectionManager.focusedKey !== null &&\n state.selectionManager.focusedKey !== undefined\n ) {\n const collectionItem = state.collection.getItem(\n state.selectionManager.focusedKey\n );\n\n const collectionItemBehavior =\n getCollectionNodeProps(collectionItem);\n\n if (\n collectionItem !== null &&\n isTruthy(collectionItemBehavior.href)\n ) {\n state.close();\n\n return { shouldPreventDefault: false };\n } else if (\n collectionItem !== null &&\n isTruthy(collectionItemBehavior.onAction)\n ) {\n collectionItemBehavior.onAction();\n state.close();\n\n return {\n shouldContinuePropagation: true,\n shouldPreventDefault: false,\n };\n }\n }\n\n if (state.isOpen) {\n state.commit();\n }\n\n return {\n shouldContinuePropagation: true,\n shouldPreventDefault: false,\n };\n },\n };\n },\n });\n\n const _result5 = createKeyboard({\n get allowRepeats(): true {\n return true;\n },\n get shortcuts() {\n return {\n ArrowDown: () => {\n state.open(\"first\", \"manual\");\n\n return { shouldPreventDefault: false };\n },\n ArrowLeft: () => {\n state.selectionManager.setFocusedKey(null);\n\n return { shouldPreventDefault: false };\n },\n ArrowRight: () => {\n state.selectionManager.setFocusedKey(null);\n\n return { shouldPreventDefault: false };\n },\n ArrowUp: () => {\n state.open(\"last\", \"manual\");\n\n return { shouldPreventDefault: false };\n },\n };\n },\n });\n\n const onBlur = (e: FocusEvent<HTMLInputElement>) => {\n const blurFromButton = nodeContains(\n buttonRef(),\n elementOrNull(e.relatedTarget)\n );\n\n const blurIntoPopover = nodeContains(\n props.popoverRef(),\n e.relatedTarget instanceof Node ? e.relatedTarget : null\n );\n\n // Ignore blur if focused moved to the button(if exists) or into the popover.\n if (blurFromButton || blurIntoPopover) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n state.setFocused(false);\n };\n\n const onFocus = (e: FocusEvent<HTMLInputElement>) => {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n state.setFocused(true);\n };\n\n const valueId = createSlotId(() => [\n state.selectionManager.selectedKeys,\n state.selectionManager.selectionMode,\n ]);\n\n const _result6 = createMemo(() => state.displayValidation);\n\n const _result7 = createTextField(\n merge(omit(props, \"validate\", \"value\", \"defaultValue\", \"onChange\"), {\n get \"aria-describedby\"() {\n return ariaValue(\n ariaValue(\n [valueId(), props[\"aria-describedby\"]].filter(Boolean).join(\" \") ||\n undefined\n )\n );\n },\n get autocomplete(): \"off\" {\n return \"off\";\n },\n get defaultValue() {\n return state.defaultInputValue;\n },\n // In multi-select mode, only set required if the selection is empty.\n get isRequired() {\n return props.selectionMode === \"multiple\"\n ? whenTruthy(props.isRequired, () => state.selectionManager.isEmpty)\n : props.isRequired;\n },\n get onBlur() {\n return onBlur;\n },\n get onChange() {\n return state.setInputValue;\n },\n get onFocus() {\n return onFocus;\n },\n get onKeyDown() {\n return isTruthy(props.isReadOnly)\n ? props.onKeyDown\n : chain(\n state.isOpen && _result3.collectionProps.onKeyDown,\n _result4.keyboardProps.onKeyDown,\n _result5.keyboardProps.onKeyDown,\n props.onKeyDown\n );\n },\n get [privateValidationStateProp]() {\n return state;\n },\n validate: undefined,\n get value() {\n return state.inputValue;\n },\n }),\n props.inputRef\n );\n\n createFormReset(\n () => props.inputRef(),\n () => state.defaultValue,\n state.setValue\n );\n\n // Press handlers for the ComboBox button\n const onPress = (e: PressEvent) => {\n if (e.pointerType === \"touch\") {\n // Focus the input field in case it isn't focused yet\n props.inputRef()?.focus();\n state.toggle(null, \"manual\");\n }\n };\n\n const onPressStart = (e: PressEvent) => {\n if (e.pointerType !== \"touch\") {\n props.inputRef()?.focus();\n state.toggle(\n e.pointerType === \"keyboard\" || e.pointerType === \"virtual\"\n ? \"first\"\n : null,\n \"manual\"\n );\n }\n };\n\n const triggerLabelProps = createLabels({\n get \"aria-label\"() {\n return ariaValue(ariaValue(stringFormatter.format(\"buttonLabel\")));\n },\n get \"aria-labelledby\"() {\n return ariaValue(\n ariaValue(\n getTruthyValue(props[\"aria-labelledby\"]) ?? _result7.labelProps.id\n )\n );\n },\n get id() {\n const { id } = _result0.menuTriggerProps;\n\n return typeof id === \"string\" ? id : undefined;\n },\n });\n\n const listBoxProps = createLabels({\n get \"aria-label\"() {\n return ariaValue(ariaValue(stringFormatter.format(\"listboxLabel\")));\n },\n get \"aria-labelledby\"() {\n return ariaValue(\n ariaValue(\n getTruthyValue(props[\"aria-labelledby\"]) ?? _result7.labelProps.id\n )\n );\n },\n get id() {\n return _result0.menuProps.id;\n },\n });\n\n // If a touch happens on direct center of ComboBox input, might be virtual click from iPad so open ComboBox menu\n let lastEventTime = 0;\n\n const onTouchEnd = (e: TouchEvent) => {\n if (isTruthy(props.isDisabled) || isTruthy(props.isReadOnly)) {\n return;\n }\n\n // Sometimes VoiceOver on iOS fires two touchend events in quick succession. Ignore the second one.\n if (e.timeStamp - lastEventTime < 500) {\n e.preventDefault();\n props.inputRef()?.focus();\n\n return;\n }\n\n const rect = getEventTarget(e).getBoundingClientRect();\n const [touch] = e.changedTouches;\n\n if (!touch) {\n return;\n }\n\n const centerX = Math.ceil(rect.left + 0.5 * rect.width);\n const centerY = Math.ceil(rect.top + 0.5 * rect.height);\n\n if (touch.clientX === centerX && touch.clientY === centerY) {\n e.preventDefault();\n props.inputRef()?.focus();\n state.toggle(null, \"manual\");\n lastEventTime = e.timeStamp;\n }\n };\n\n // VoiceOver announces per-item details natively, so only announce when entering a\n // new section, where it is silent.\n const focusedItem = createMemo(() =>\n isPresent(state.selectionManager.focusedKey) && state.isOpen\n ? state.collection.getItem(state.selectionManager.focusedKey)\n : undefined\n );\n\n const sectionKey = createMemo(() => focusedItem()?.parentKey ?? null);\n\n const itemKey = createMemo(() => state.selectionManager.focusedKey ?? null);\n\n let lastSection = untrack(sectionKey);\n let lastItem = untrack(itemKey);\n createEffect(\n () => {\n const currentItem = focusedItem();\n const currentItemKey = itemKey();\n const currentSectionKey = sectionKey();\n let announcement: string | undefined;\n\n if (\n isAppleDevice() &&\n currentItem &&\n currentItemKey !== null &&\n currentItemKey !== lastItem\n ) {\n const { collection } = state;\n\n const section =\n currentSectionKey === null\n ? null\n : collection.getItem(currentSectionKey);\n\n if (section && currentSectionKey !== lastSection) {\n announcement = stringFormatter.format(\"focusAnnouncement\", {\n groupCount: [...getChildNodes(section, collection)].length,\n groupTitle:\n getTruthyValue(\n getTruthyValue(section[\"aria-label\"]) ??\n (typeof section.rendered === \"string\" ? section.rendered : \"\")\n ) ?? \"\",\n isGroupChange: true,\n isSelected: state.selectionManager.isSelected(currentItemKey),\n optionText:\n getTruthyValue(\n getTruthyValue(currentItem[\"aria-label\"]) ??\n currentItem.textValue\n ) ?? \"\",\n });\n }\n }\n\n return { announcement, currentItemKey, currentSectionKey };\n },\n ({ announcement, currentItemKey, currentSectionKey }) => {\n if (announcement !== undefined && announcement !== \"\") {\n announce(announcement);\n }\n\n lastSection = currentSectionKey;\n lastItem = currentItemKey;\n },\n { ssrSource: \"client\" }\n );\n // Announce the number of available suggestions when it changes.\n const optionCount = createMemo(() => getItemCount(state.collection));\n let lastSize = untrack(optionCount);\n let lastOpen = untrack(() => state.isOpen);\n createEffect(\n () => {\n const { isOpen } = state;\n const observedOptionCount = optionCount();\n\n // Other screen readers read the focused item's position automatically.\n const didOpenWithoutFocusedItem =\n isOpen !== lastOpen &&\n (!isPresent(state.selectionManager.focusedKey) || isAppleDevice());\n\n const announcement =\n isOpen &&\n (didOpenWithoutFocusedItem || observedOptionCount !== lastSize)\n ? stringFormatter.format(\"countAnnouncement\", {\n optionCount: observedOptionCount,\n })\n : undefined;\n\n return { announcement, isOpen, observedOptionCount };\n },\n ({ announcement, isOpen, observedOptionCount }) => {\n if (announcement !== undefined && announcement !== \"\") {\n announce(announcement);\n }\n\n lastSize = observedOptionCount;\n lastOpen = isOpen;\n },\n { ssrSource: \"client\" }\n );\n // VoiceOver needs an explicit selection announcement.\n // Follow-up: do we need to do this for multi-select?\n let lastSelectedKey = untrack(() => getLegacyOption(state, \"selectedKey\"));\n createEffect(\n () => {\n const selectedItem = getLegacyOption(state, \"selectedItem\");\n const selectedKey = getLegacyOption(state, \"selectedKey\");\n\n const announcement =\n isAppleDevice() &&\n state.isFocused &&\n selectedItem &&\n selectedKey !== lastSelectedKey\n ? stringFormatter.format(\"selectedAnnouncement\", {\n optionText:\n getTruthyValue(\n getTruthyValue(selectedItem[\"aria-label\"]) ??\n selectedItem.textValue\n ) ?? \"\",\n })\n : undefined;\n\n return { announcement, selectedKey };\n },\n ({ announcement, selectedKey }) => {\n if (announcement !== undefined && announcement !== \"\") {\n announce(announcement);\n }\n\n lastSelectedKey = selectedKey;\n },\n { ssrSource: \"client\" }\n );\n createEffect(\n () => ({\n inputElement: props.inputRef(),\n isOpen: state.isOpen,\n popoverElement: props.popoverRef(),\n }),\n ({ popoverElement, inputElement, isOpen }): undefined | (() => void) => {\n if (isOpen) {\n return ariaHideOutside(\n [inputElement, popoverElement].filter((element) => isPresent(element))\n );\n }\n\n return undefined;\n },\n { ssrSource: \"client\" }\n );\n createEffect(\n () => ({ focusedItem: focusedItem(), inputElement: props.inputRef() }),\n ({ focusedItem: currentFocusedItem, inputElement }) => {\n const propsinputRefElement = inputElement;\n\n // Re-show focus ring when there is no virtually focused item.\n if (\n !currentFocusedItem &&\n propsinputRefElement &&\n getActiveElement(getOwnerDocument(propsinputRefElement)) ===\n propsinputRefElement\n ) {\n dispatchVirtualFocus(propsinputRefElement, null);\n }\n },\n { defer: true, ssrSource: \"client\" }\n );\n createEvent(props.listBoxRef, \"react-aria-item-action\", () => {\n if (state.isOpen) {\n state.close();\n }\n });\n\n return {\n get buttonProps() {\n const trigger = _result0.menuTriggerProps;\n\n return merge(triggerLabelProps, {\n get \"aria-controls\"() {\n const { id } = _result0.menuProps;\n\n return state.isOpen && typeof id === \"string\" ? id : undefined;\n },\n get \"aria-expanded\"() {\n return state.isOpen;\n },\n get \"aria-haspopup\"() {\n return \"listbox\" as const;\n },\n excludeFromTabOrder: true,\n get isDisabled() {\n return getTruthyValue(props.isDisabled) ?? props.isReadOnly;\n },\n onKeyDown: (event: KeyboardEvent) => trigger.onKeyDown?.(event),\n onKeyUp: (event: KeyboardEvent) => trigger.onKeyUp?.(event),\n onPress,\n onPressStart,\n preventFocusOnPress: true,\n });\n },\n get descriptionProps() {\n return _result7.descriptionProps;\n },\n get errorMessageProps() {\n return _result7.errorMessageProps;\n },\n get inputProps() {\n return mergeProps(_result7.inputProps, {\n \"aria-activedescendant\": ariaValue(\n focusedItem()\n ? getItemId(\n state,\n requireValue(focusedItem(), \"Expected focusedItem()\").key\n )\n : undefined\n ),\n // Follow-up: readd proper logic for completionMode = complete (aria-autocomplete: both)\n \"aria-autocomplete\": ariaValue(\"list\"),\n \"aria-controls\": ariaValue(\n state.isOpen ? _result0.menuProps.id : undefined\n ),\n \"aria-expanded\": ariaValue(_result0.menuTriggerProps[\"aria-expanded\"]),\n // This disable's iOS's autocorrect suggestions, since the combo box provides its own suggestions.\n autocorrect: \"off\",\n onTouchEnd,\n role: \"combobox\",\n // This disable's the macOS Safari spell check auto corrections.\n spellcheck: \"false\",\n });\n },\n get isInvalid() {\n return _result6().isInvalid;\n },\n get labelProps() {\n return merge(\n {\n get for() {\n const value =\n \"for\" in _result7.labelProps\n ? _result7.labelProps.for\n : undefined;\n\n return typeof value === \"string\" ? value : undefined;\n },\n get id() {\n const { id } = _result7.labelProps;\n\n return typeof id === \"string\" ? id : undefined;\n },\n },\n {\n // Focus the input in case the label is not a native <label> element.\n get onClick() {\n return (\"for\" in _result7.labelProps &&\n isTruthy(_result7.labelProps.for)) ||\n isTruthy(props.isDisabled)\n ? undefined\n : () => {\n props.inputRef()?.focus();\n setInteractionModality(\"keyboard\");\n };\n },\n }\n );\n },\n get listBoxProps() {\n return mergeProps(_result0.menuProps, listBoxProps, {\n UNSTABLE_itemBehavior: \"action\" as const,\n autoFocus: getTruthyValue(state.focusStrategy) ?? true,\n linkBehavior: \"selection\" as const,\n onAction: undefined,\n shouldFocusOnHover: true,\n shouldSelectOnPressUp: true,\n shouldUseVirtualFocus: true,\n });\n },\n get validationDetails() {\n return _result6().validationDetails;\n },\n get validationErrors() {\n return _result6().validationErrors;\n },\n get valueProps() {\n return {\n get id() {\n return valueId();\n },\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6IA,SAAgB,eACd,OACA,OACiB;CACjB,MAAM,YAAY,MAAM,oBAAoB;CAE5C,MAAM,kBAAkB,+BACtBA,kBACA,sBACF;CAEA,MAAM,WAAW,kBACf;EACE,IAAI,aAAa;GACf,OAAO,eAAe,MAAM,UAAU,KAAK,MAAM;EACnD;EACA,IAAI,OAAkB;GACpB,OAAO;EACT;CACF,GACA,OACA,SACF;CAGA,SAAS,IAAI,OAAO,EAClB,IAAI,KAAK;EACP,OAAO,SAAS,UAAU;CAC5B,EACF,CAAC;CAGD,MAAM,WAAW;CACjB,MAAM,WAAW,cAAc,MAAM,gBAAgB;CAErD,MAAM,WAAW,iBAEb,eAAe,MAAM,gBAAgB,KACrC,IAAI,qBAAqB;EACvB,YAAY,SAAS;EACrB,cAAc,SAAS;EACvB,gBAAgB,MAAM;EACtB,KAAK,MAAM;CACb,CAAC,CACL;CAGA,MAAM,WAAW,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AiB,gBAAgB;IAErE,aAAa;IACb;IACA,MAAM;IAEN,YAAY;GACd,CAAC;EACH;EACA,IAAI,YAAY;GACd,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,aAAa;GACf,OAAO,MACL;IACE,IAAI,MAAM;KACR,MAAM,QACJ,SAAS,SAAS,aACd,SAAS,WAAW,MACpB,KAAA;KAEN,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAA;IAC7C;IACA,IAAI,KAAK;KACP,MAAM,EAAE,OAAO,SAAS;KAExB,OAAO,OAAO,OAAO,WAAW,KAAK,KAAA;IACvC;GACF,GACA,EAEE,IAAI,UAAU;IACZ,OAAQ,SAAS,SAAS,cACxB,SAAS,SAAS,WAAW,GAAG,KAChC,SAAS,MAAM,UAAU,IACvB,KAAA,UACM;KACJ,MAAM,SAAS,CAAC,EAAE,MAAM;KACxB,uBAAuB,UAAU;IACnC;GACN,EACF,CACF;EACF;EACA,IAAI,eAAe;GACjB,OAAO,WAAW,SAAS,WAAW,cAAc;IAClD,uBAAuB;IACvB,WAAW,eAAe,MAAM,aAAa,KAAK;IAClD,cAAc;IACd,UAAU,KAAA;IACV,oBAAoB;IACpB,uBAAuB;IACvB,uBAAuB;GACzB,CAAC;EACH;EACA,IAAI,oBAAoB;GACtB,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,mBAAmB;GACrB,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,aAAa;GACf,OAAO,EACL,IAAI,KAAK;IACP,OAAO,QAAQ;GACjB,EACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"create-combo-box.js","names":["intlMessages"],"sources":["../../../src/combobox/create-combo-box.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/combobox/useComboBox.ts.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2; compute localized announcements in tracking scopes before publishing them from effects.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport { getChildNodes } from \"@solid2-aria/stately/collections/get-child-nodes\";\nimport { getItemCount } from \"@solid2-aria/stately/collections/get-item-count\";\nimport type {\n ComboBoxProps,\n ComboBoxState,\n} from \"@solid2-aria/stately/combobox/create-combo-box-state\";\nimport { privateValidationStateProp } from \"@solid2-aria/stately/form/create-form-validation-state\";\nimport type { SelectionMode } from \"@solid2-aria/stately/select/create-select-state\";\nimport type {\n KeyboardEvent,\n AriaLabelingProps,\n DOMProps,\n InputDOMProps,\n KeyboardDelegate,\n LayoutDelegate,\n PressEvent,\n ValidationResult,\n} from \"@solid2-aria/types-shared\";\nimport type { DOMAttributes } from \"@solid2-aria/types-shared-web\";\nimport { merge, omit, createEffect, createMemo, untrack } from \"solid-js\";\nimport type { Accessor } from \"solid-js\";\n\nimport intlMessages from \"../../intl/combobox/index\";\nimport type { AriaButtonProps } from \"../button/create-button\";\nimport {\n dispatchVirtualFocus,\n getOriginalRelatedTarget,\n} from \"../focus/virtual-focus\";\nimport { createLocalizedStringFormatter } from \"../i18n/create-localized-string-formatter\";\nimport { setInteractionModality } from \"../interactions/create-focus-visible\";\nimport { createKeyboard } from \"../interactions/create-keyboard\";\nimport type { FieldAria } from \"../label/create-field\";\nimport type { AriaListBoxOptions } from \"../listbox/create-list-box\";\nimport { getItemId, listData } from \"../listbox/utils\";\nimport { announce } from \"../live-announcer/live-announcer\";\nimport { createMenuTrigger } from \"../menu/create-menu-trigger\";\nimport { ariaHideOutside } from \"../overlays/aria-hide-outside\";\nimport { createSelectableCollection } from \"../selection/create-selectable-collection\";\nimport { ListKeyboardDelegate } from \"../selection/list-keyboard-delegate\";\nimport { createTextField } from \"../textfield/create-text-field\";\nimport type {\n ElementType,\n FocusEvent,\n InputHTMLAttributes,\n TouchEvent,\n} from \"../types\";\nimport { ariaValue } from \"../utils/aria-value\";\nimport { chain } from \"../utils/chain\";\nimport { createEvent } from \"../utils/create-event\";\nimport { createFormReset } from \"../utils/create-form-reset\";\nimport { createSlotId } from \"../utils/create-id\";\nimport { createLabels } from \"../utils/create-labels\";\nimport { getOwnerDocument } from \"../utils/dom-helpers\";\nimport { elementOrNull } from \"../utils/dom-value\";\nimport { getCollectionNodeProps } from \"../utils/get-collection-node-props\";\nimport { isPresent } from \"../utils/is-present\";\nimport { getLegacyOption } from \"../utils/legacy-option\";\nimport { mergeProps } from \"../utils/merge-props\";\nimport { createRouter } from \"../utils/open-link\";\nimport { isAppleDevice } from \"../utils/platform\";\nimport { requireValue } from \"../utils/require-value\";\nimport {\n getActiveElement,\n getEventTarget,\n nodeContains,\n} from \"../utils/shadowdom/dom-functions\";\nimport { getTruthyValue, isTruthy, whenTruthy } from \"../utils/truthy\";\n\nexport interface AriaComboBoxProps<T, M extends SelectionMode = \"single\">\n extends ComboBoxProps<T, M>, DOMProps, InputDOMProps, AriaLabelingProps {\n /** Whether keyboard navigation is circular. */\n shouldFocusWrap?: boolean;\n}\n\nexport interface AriaComboBoxOptions<\n T,\n M extends SelectionMode = \"single\",\n> extends Omit<AriaComboBoxProps<T, M>, \"children\"> {\n /** The ref for the input element. */\n inputRef: Accessor<HTMLInputElement | null>;\n /** The ref for the list box popover. */\n popoverRef: Accessor<Element | null>;\n /** The ref for the list box. */\n listBoxRef: Accessor<HTMLElement | null>;\n /** The ref for the optional list box popup trigger button. */\n buttonRef?: Accessor<Element | null>;\n /**\n * The HTML element used to render the label, e.g. 'label', or 'span'.\n *\n * @default 'label'\n */\n labelElementType?: ElementType;\n /** An optional keyboard delegate implementation, to override the default. */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n}\n\nexport interface ComboBoxAria<T> extends ValidationResult {\n /** Props for the label element. */\n labelProps: FieldAria[\"labelProps\"];\n /** Props for the combo box input element. */\n inputProps: InputHTMLAttributes;\n /** Props for the list box, to be passed to `useListBox`. */\n listBoxProps: AriaListBoxOptions<T>;\n /** Props for the optional trigger button, to be passed to `useButton`. */\n buttonProps: AriaButtonProps;\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n /** Props for the combo box description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the combo box error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a combo box component. A combo box\n * combines a text input with a listbox, allowing users to filter a list of options to items\n * matching a query.\n *\n * @param props - Props for the combo box.\n * @param state - State for the select, as returned by `useComboBoxState`.\n */\nexport function createComboBox<T, M extends SelectionMode = \"single\">(\n props: AriaComboBoxOptions<T, M>,\n state: ComboBoxState<T, M>\n): ComboBoxAria<T> {\n const buttonRef = props.buttonRef ?? (() => null);\n\n const stringFormatter = createLocalizedStringFormatter(\n intlMessages,\n \"@react-aria/combobox\"\n );\n\n const _result0 = createMenuTrigger<T>(\n {\n get isDisabled() {\n return getTruthyValue(props.isDisabled) ?? props.isReadOnly;\n },\n get type(): \"listbox\" {\n return \"listbox\";\n },\n },\n state,\n buttonRef\n );\n\n // Set listbox id so it can be used when calling getItemId later\n listData.set(state, {\n get id() {\n return _result0.menuProps.id;\n },\n });\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n const _result1 = state;\n const _result2 = untrack(() => state.selectionManager);\n\n const delegate = createMemo(\n () =>\n getTruthyValue(props.keyboardDelegate) ??\n new ListKeyboardDelegate({\n collection: _result1.collection,\n disabledKeys: _result2.disabledKeys,\n layoutDelegate: props.layoutDelegate,\n ref: props.listBoxRef,\n })\n );\n\n // Use useSelectableCollection to get the keyboard handlers to apply to the textfield\n const _result3 = createSelectableCollection({\n get disallowEmptySelection(): true {\n return true;\n },\n get disallowTypeAhead(): true {\n return true;\n },\n // Prevent item scroll behavior from being applied here, should be handled in the user's Popover + ListBox component\n get isVirtualized(): true {\n return true;\n },\n get keyboardDelegate() {\n return delegate();\n },\n get ref() {\n return props.inputRef;\n },\n get selectionManager() {\n return state.selectionManager;\n },\n get shouldFocusWrap() {\n return props.shouldFocusWrap;\n },\n });\n\n const router = createRouter();\n\n // for textfield specific operations\n const _result4 = createKeyboard({\n get shortcuts() {\n return {\n Enter: (e: KeyboardEvent) => {\n const propslistBoxRefElement = props.listBoxRef();\n // Prevent default form submission if menu is open since we may be selecting a option\n const shouldPreventDefault = state.isOpen;\n\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (\n state.isOpen &&\n propslistBoxRefElement &&\n state.selectionManager.focusedKey !== null &&\n state.selectionManager.focusedKey !== undefined\n ) {\n const collectionItem = state.collection.getItem(\n state.selectionManager.focusedKey\n );\n\n const collectionItemBehavior =\n getCollectionNodeProps(collectionItem);\n\n if (\n collectionItem !== null &&\n isTruthy(collectionItemBehavior.href)\n ) {\n const item = propslistBoxRefElement.querySelector(\n `[data-key=\"${CSS.escape(state.selectionManager.focusedKey.toString())}\"]`\n );\n\n if (item instanceof HTMLAnchorElement) {\n router.open(\n item,\n e,\n collectionItemBehavior.href,\n collectionItemBehavior.routerOptions\n );\n }\n\n state.close();\n\n return { shouldPreventDefault };\n } else if (\n collectionItem !== null &&\n isTruthy(collectionItemBehavior.onAction)\n ) {\n collectionItemBehavior.onAction();\n state.close();\n\n return { shouldPreventDefault };\n }\n }\n\n state.commit();\n\n return { shouldPreventDefault };\n },\n Escape: () => {\n let shouldContinuePropagation = false;\n\n if (\n !state.selectionManager.isEmpty ||\n state.inputValue === \"\" ||\n isTruthy(props.allowsCustomValue)\n ) {\n shouldContinuePropagation = true;\n }\n\n state.revert();\n\n return { shouldContinuePropagation };\n },\n Tab: () => {\n // If the focused item is a link, trigger opening it. Items that are links are not selectable.\n if (\n state.isOpen &&\n props.listBoxRef() &&\n state.selectionManager.focusedKey !== null &&\n state.selectionManager.focusedKey !== undefined\n ) {\n const collectionItem = state.collection.getItem(\n state.selectionManager.focusedKey\n );\n\n const collectionItemBehavior =\n getCollectionNodeProps(collectionItem);\n\n if (\n collectionItem !== null &&\n isTruthy(collectionItemBehavior.href)\n ) {\n state.close();\n\n return { shouldPreventDefault: false };\n } else if (\n collectionItem !== null &&\n isTruthy(collectionItemBehavior.onAction)\n ) {\n collectionItemBehavior.onAction();\n state.close();\n\n return {\n shouldContinuePropagation: true,\n shouldPreventDefault: false,\n };\n }\n }\n\n if (state.isOpen) {\n state.commit();\n }\n\n return {\n shouldContinuePropagation: true,\n shouldPreventDefault: false,\n };\n },\n };\n },\n });\n\n const _result5 = createKeyboard({\n get allowRepeats(): true {\n return true;\n },\n get shortcuts() {\n return {\n ArrowDown: () => {\n state.open(\"first\", \"manual\");\n\n return { shouldPreventDefault: false };\n },\n ArrowLeft: () => {\n state.selectionManager.setFocusedKey(null);\n\n return { shouldPreventDefault: false };\n },\n ArrowRight: () => {\n state.selectionManager.setFocusedKey(null);\n\n return { shouldPreventDefault: false };\n },\n ArrowUp: () => {\n state.open(\"last\", \"manual\");\n\n return { shouldPreventDefault: false };\n },\n };\n },\n });\n\n const onBlur = (e: FocusEvent<HTMLInputElement>) => {\n const blurFromButton = nodeContains(\n buttonRef(),\n elementOrNull(e.relatedTarget)\n );\n\n const blurIntoPopover = nodeContains(\n props.popoverRef(),\n getOriginalRelatedTarget(e)\n );\n\n // Ignore blur if focused moved to the button(if exists) or into the popover.\n if (blurFromButton || blurIntoPopover) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n state.setFocused(false);\n };\n\n const onFocus = (e: FocusEvent<HTMLInputElement>) => {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n state.setFocused(true);\n };\n\n const valueId = createSlotId(() => [\n state.selectionManager.selectedKeys,\n state.selectionManager.selectionMode,\n ]);\n\n const _result6 = createMemo(() => state.displayValidation);\n\n const _result7 = createTextField(\n merge(omit(props, \"validate\", \"value\", \"defaultValue\", \"onChange\"), {\n get \"aria-describedby\"() {\n return ariaValue(\n ariaValue(\n [valueId(), props[\"aria-describedby\"]].filter(Boolean).join(\" \") ||\n undefined\n )\n );\n },\n get autocomplete(): \"off\" {\n return \"off\";\n },\n get defaultValue() {\n return state.defaultInputValue;\n },\n // In multi-select mode, only set required if the selection is empty.\n get isRequired() {\n return props.selectionMode === \"multiple\"\n ? whenTruthy(props.isRequired, () => state.selectionManager.isEmpty)\n : props.isRequired;\n },\n get onBlur() {\n return onBlur;\n },\n get onChange() {\n return state.setInputValue;\n },\n get onFocus() {\n return onFocus;\n },\n get onKeyDown() {\n return isTruthy(props.isReadOnly)\n ? props.onKeyDown\n : chain(\n state.isOpen && _result3.collectionProps.onKeyDown,\n _result4.keyboardProps.onKeyDown,\n _result5.keyboardProps.onKeyDown,\n props.onKeyDown\n );\n },\n get [privateValidationStateProp]() {\n return state;\n },\n validate: undefined,\n get value() {\n return state.inputValue;\n },\n }),\n props.inputRef\n );\n\n createFormReset(\n () => props.inputRef(),\n () => state.defaultValue,\n state.setValue\n );\n\n // Press handlers for the ComboBox button\n const onPress = (e: PressEvent) => {\n if (e.pointerType === \"touch\") {\n // Focus the input field in case it isn't focused yet\n props.inputRef()?.focus();\n state.toggle(null, \"manual\");\n }\n };\n\n const onPressStart = (e: PressEvent) => {\n if (e.pointerType !== \"touch\") {\n props.inputRef()?.focus();\n state.toggle(\n e.pointerType === \"keyboard\" || e.pointerType === \"virtual\"\n ? \"first\"\n : null,\n \"manual\"\n );\n }\n };\n\n const triggerLabelProps = createLabels({\n get \"aria-label\"() {\n return ariaValue(ariaValue(stringFormatter.format(\"buttonLabel\")));\n },\n get \"aria-labelledby\"() {\n return ariaValue(\n ariaValue(\n getTruthyValue(props[\"aria-labelledby\"]) ?? _result7.labelProps.id\n )\n );\n },\n get id() {\n const { id } = _result0.menuTriggerProps;\n\n return typeof id === \"string\" ? id : undefined;\n },\n });\n\n const listBoxProps = createLabels({\n get \"aria-label\"() {\n return ariaValue(ariaValue(stringFormatter.format(\"listboxLabel\")));\n },\n get \"aria-labelledby\"() {\n return ariaValue(\n ariaValue(\n getTruthyValue(props[\"aria-labelledby\"]) ?? _result7.labelProps.id\n )\n );\n },\n get id() {\n return _result0.menuProps.id;\n },\n });\n\n // If a touch happens on direct center of ComboBox input, might be virtual click from iPad so open ComboBox menu\n let lastEventTime = 0;\n\n const onTouchEnd = (e: TouchEvent) => {\n if (isTruthy(props.isDisabled) || isTruthy(props.isReadOnly)) {\n return;\n }\n\n // Sometimes VoiceOver on iOS fires two touchend events in quick succession. Ignore the second one.\n if (e.timeStamp - lastEventTime < 500) {\n e.preventDefault();\n props.inputRef()?.focus();\n\n return;\n }\n\n const rect = getEventTarget(e).getBoundingClientRect();\n const [touch] = e.changedTouches;\n\n if (!touch) {\n return;\n }\n\n const centerX = Math.ceil(rect.left + 0.5 * rect.width);\n const centerY = Math.ceil(rect.top + 0.5 * rect.height);\n\n if (touch.clientX === centerX && touch.clientY === centerY) {\n e.preventDefault();\n props.inputRef()?.focus();\n state.toggle(null, \"manual\");\n lastEventTime = e.timeStamp;\n }\n };\n\n // VoiceOver announces per-item details natively, so only announce when entering a\n // new section, where it is silent.\n const focusedItem = createMemo(() =>\n isPresent(state.selectionManager.focusedKey) && state.isOpen\n ? state.collection.getItem(state.selectionManager.focusedKey)\n : undefined\n );\n\n const sectionKey = createMemo(() => focusedItem()?.parentKey ?? null);\n\n const itemKey = createMemo(() => state.selectionManager.focusedKey ?? null);\n\n let lastSection = untrack(sectionKey);\n let lastItem = untrack(itemKey);\n createEffect(\n () => {\n const currentItem = focusedItem();\n const currentItemKey = itemKey();\n const currentSectionKey = sectionKey();\n let announcement: string | undefined;\n\n if (\n isAppleDevice() &&\n currentItem &&\n currentItemKey !== null &&\n currentItemKey !== lastItem\n ) {\n const { collection } = state;\n\n const section =\n currentSectionKey === null\n ? null\n : collection.getItem(currentSectionKey);\n\n if (section && currentSectionKey !== lastSection) {\n announcement = stringFormatter.format(\"focusAnnouncement\", {\n groupCount: [...getChildNodes(section, collection)].length,\n groupTitle:\n getTruthyValue(\n getTruthyValue(section[\"aria-label\"]) ??\n (typeof section.rendered === \"string\" ? section.rendered : \"\")\n ) ?? \"\",\n isGroupChange: true,\n isSelected: state.selectionManager.isSelected(currentItemKey),\n optionText:\n getTruthyValue(\n getTruthyValue(currentItem[\"aria-label\"]) ??\n currentItem.textValue\n ) ?? \"\",\n });\n }\n }\n\n return { announcement, currentItemKey, currentSectionKey };\n },\n ({ announcement, currentItemKey, currentSectionKey }) => {\n if (announcement !== undefined && announcement !== \"\") {\n announce(announcement);\n }\n\n lastSection = currentSectionKey;\n lastItem = currentItemKey;\n },\n { ssrSource: \"client\" }\n );\n // Announce the number of available suggestions when it changes.\n const optionCount = createMemo(() => getItemCount(state.collection));\n let lastSize = untrack(optionCount);\n let lastOpen = untrack(() => state.isOpen);\n createEffect(\n () => {\n const { isOpen } = state;\n const observedOptionCount = optionCount();\n\n // Other screen readers read the focused item's position automatically.\n const didOpenWithoutFocusedItem =\n isOpen !== lastOpen &&\n (!isPresent(state.selectionManager.focusedKey) || isAppleDevice());\n\n const announcement =\n isOpen &&\n (didOpenWithoutFocusedItem || observedOptionCount !== lastSize)\n ? stringFormatter.format(\"countAnnouncement\", {\n optionCount: observedOptionCount,\n })\n : undefined;\n\n return { announcement, isOpen, observedOptionCount };\n },\n ({ announcement, isOpen, observedOptionCount }) => {\n if (announcement !== undefined && announcement !== \"\") {\n announce(announcement);\n }\n\n lastSize = observedOptionCount;\n lastOpen = isOpen;\n },\n { ssrSource: \"client\" }\n );\n // VoiceOver needs an explicit selection announcement.\n // Follow-up: do we need to do this for multi-select?\n let lastSelectedKey = untrack(() => getLegacyOption(state, \"selectedKey\"));\n createEffect(\n () => {\n const selectedItem = getLegacyOption(state, \"selectedItem\");\n const selectedKey = getLegacyOption(state, \"selectedKey\");\n\n const announcement =\n isAppleDevice() &&\n state.isFocused &&\n selectedItem &&\n selectedKey !== lastSelectedKey\n ? stringFormatter.format(\"selectedAnnouncement\", {\n optionText:\n getTruthyValue(\n getTruthyValue(selectedItem[\"aria-label\"]) ??\n selectedItem.textValue\n ) ?? \"\",\n })\n : undefined;\n\n return { announcement, selectedKey };\n },\n ({ announcement, selectedKey }) => {\n if (announcement !== undefined && announcement !== \"\") {\n announce(announcement);\n }\n\n lastSelectedKey = selectedKey;\n },\n { ssrSource: \"client\" }\n );\n createEffect(\n () => ({\n inputElement: props.inputRef(),\n isOpen: state.isOpen,\n popoverElement: props.popoverRef(),\n }),\n ({ popoverElement, inputElement, isOpen }): undefined | (() => void) => {\n if (isOpen) {\n return ariaHideOutside(\n [inputElement, popoverElement].filter((element) => isPresent(element))\n );\n }\n\n return undefined;\n },\n { ssrSource: \"client\" }\n );\n createEffect(\n () => ({ focusedItem: focusedItem(), inputElement: props.inputRef() }),\n ({ focusedItem: currentFocusedItem, inputElement }) => {\n const propsinputRefElement = inputElement;\n\n // Re-show focus ring when there is no virtually focused item.\n if (\n !currentFocusedItem &&\n propsinputRefElement &&\n getActiveElement(getOwnerDocument(propsinputRefElement)) ===\n propsinputRefElement\n ) {\n dispatchVirtualFocus(propsinputRefElement, null);\n }\n },\n { defer: true, ssrSource: \"client\" }\n );\n createEvent(props.listBoxRef, \"react-aria-item-action\", () => {\n if (state.isOpen) {\n state.close();\n }\n });\n\n return {\n get buttonProps() {\n const trigger = _result0.menuTriggerProps;\n\n return merge(triggerLabelProps, {\n get \"aria-controls\"() {\n const { id } = _result0.menuProps;\n\n return state.isOpen && typeof id === \"string\" ? id : undefined;\n },\n get \"aria-expanded\"() {\n return state.isOpen;\n },\n get \"aria-haspopup\"() {\n return \"listbox\" as const;\n },\n excludeFromTabOrder: true,\n get isDisabled() {\n return getTruthyValue(props.isDisabled) ?? props.isReadOnly;\n },\n onKeyDown: (event: KeyboardEvent) => trigger.onKeyDown?.(event),\n onKeyUp: (event: KeyboardEvent) => trigger.onKeyUp?.(event),\n onPress,\n onPressStart,\n preventFocusOnPress: true,\n });\n },\n get descriptionProps() {\n return _result7.descriptionProps;\n },\n get errorMessageProps() {\n return _result7.errorMessageProps;\n },\n get inputProps() {\n return mergeProps(_result7.inputProps, {\n \"aria-activedescendant\": ariaValue(\n focusedItem()\n ? getItemId(\n state,\n requireValue(focusedItem(), \"Expected focusedItem()\").key\n )\n : undefined\n ),\n // Follow-up: readd proper logic for completionMode = complete (aria-autocomplete: both)\n \"aria-autocomplete\": ariaValue(\"list\"),\n \"aria-controls\": ariaValue(\n state.isOpen ? _result0.menuProps.id : undefined\n ),\n \"aria-expanded\": ariaValue(_result0.menuTriggerProps[\"aria-expanded\"]),\n // This disable's iOS's autocorrect suggestions, since the combo box provides its own suggestions.\n autocorrect: \"off\",\n onTouchEnd,\n role: \"combobox\",\n // This disable's the macOS Safari spell check auto corrections.\n spellcheck: \"false\",\n });\n },\n get isInvalid() {\n return _result6().isInvalid;\n },\n get labelProps() {\n return merge(\n {\n get for() {\n const value =\n \"for\" in _result7.labelProps\n ? _result7.labelProps.for\n : undefined;\n\n return typeof value === \"string\" ? value : undefined;\n },\n get id() {\n const { id } = _result7.labelProps;\n\n return typeof id === \"string\" ? id : undefined;\n },\n },\n {\n // Focus the input in case the label is not a native <label> element.\n get onClick() {\n return (\"for\" in _result7.labelProps &&\n isTruthy(_result7.labelProps.for)) ||\n isTruthy(props.isDisabled)\n ? undefined\n : () => {\n props.inputRef()?.focus();\n setInteractionModality(\"keyboard\");\n };\n },\n }\n );\n },\n get listBoxProps() {\n return mergeProps(_result0.menuProps, listBoxProps, {\n UNSTABLE_itemBehavior: \"action\" as const,\n autoFocus: getTruthyValue(state.focusStrategy) ?? true,\n linkBehavior: \"selection\" as const,\n onAction: undefined,\n shouldFocusOnHover: true,\n shouldSelectOnPressUp: true,\n shouldUseVirtualFocus: true,\n });\n },\n get validationDetails() {\n return _result6().validationDetails;\n },\n get validationErrors() {\n return _result6().validationErrors;\n },\n get valueProps() {\n return {\n get id() {\n return valueId();\n },\n };\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgJA,SAAgB,eACd,OACA,OACiB;CACjB,MAAM,YAAY,MAAM,oBAAoB;CAE5C,MAAM,kBAAkB,+BACtBA,kBACA,sBACF;CAEA,MAAM,WAAW,kBACf;EACE,IAAI,aAAa;GACf,OAAO,eAAe,MAAM,UAAU,KAAK,MAAM;EACnD;EACA,IAAI,OAAkB;GACpB,OAAO;EACT;CACF,GACA,OACA,SACF;CAGA,SAAS,IAAI,OAAO,EAClB,IAAI,KAAK;EACP,OAAO,SAAS,UAAU;CAC5B,EACF,CAAC;CAGD,MAAM,WAAW;CACjB,MAAM,WAAW,cAAc,MAAM,gBAAgB;CAErD,MAAM,WAAW,iBAEb,eAAe,MAAM,gBAAgB,KACrC,IAAI,qBAAqB;EACvB,YAAY,SAAS;EACrB,cAAc,SAAS;EACvB,gBAAgB,MAAM;EACtB,KAAK,MAAM;CACb,CAAC,CACL;CAGA,MAAM,WAAW,2BAA2B;EAC1C,IAAI,yBAA+B;GACjC,OAAO;EACT;EACA,IAAI,oBAA0B;GAC5B,OAAO;EACT;EAEA,IAAI,gBAAsB;GACxB,OAAO;EACT;EACA,IAAI,mBAAmB;GACrB,OAAO,SAAS;EAClB;EACA,IAAI,MAAM;GACR,OAAO,MAAM;EACf;EACA,IAAI,mBAAmB;GACrB,OAAO,MAAM;EACf;EACA,IAAI,kBAAkB;GACpB,OAAO,MAAM;EACf;CACF,CAAC;CAED,MAAM,SAAS,aAAa;CAG5B,MAAM,WAAW,eAAe,EAC9B,IAAI,YAAY;EACd,OAAO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AAU;IACZ,OAAQ,SAAS,SAAS,cACxB,SAAS,SAAS,WAAW,GAAG,KAChC,SAAS,MAAM,UAAU,IACvB,KAAA,UACM;KACJ,MAAM,SAAS,CAAC,EAAE,MAAM;KACxB,uBAAuB,UAAU;IACnC;GACN,EACF,CACF;EACF;EACA,IAAI,eAAe;GACjB,OAAO,WAAW,SAAS,WAAW,cAAc;IAClD,uBAAuB;IACvB,WAAW,eAAe,MAAM,aAAa,KAAK;IAClD,cAAc;IACd,UAAU,KAAA;IACV,oBAAoB;IACpB,uBAAuB;IACvB,uBAAuB;GACzB,CAAC;EACH;EACA,IAAI,oBAAoB;GACtB,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,mBAAmB;GACrB,OAAO,SAAS,CAAC,CAAC;EACpB;EACA,IAAI,aAAa;GACf,OAAO,EACL,IAAI,KAAK;IACP,OAAO,QAAQ;GACjB,EACF;EACF;CACF;AACF"}
@@ -15,8 +15,8 @@
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 { isTruthy } from "../utils/truthy.js";
18
- import { escape, scope, ssr, ssrHydrationKey, ssrStyleProperties } from "@solidjs/web";
19
- import { Show, createSignal, flush, onSettled } from "solid-js";
18
+ import { escape, memo, scope, ssr, ssrHydrationKey, ssrStyleProperties } from "@solidjs/web";
19
+ import { createSignal, flush, onSettled } from "solid-js";
20
20
  // src/dnd/drag-preview.tsx
21
21
  var _tmpl$ = [
22
22
  "<div",
@@ -25,7 +25,6 @@ var _tmpl$ = [
25
25
  "</div>"
26
26
  ];
27
27
  function DragPreview(props) {
28
- var _v$, _v$2;
29
28
  const [preview, setPreview] = createSignal(null);
30
29
  let frame;
31
30
  const renderPreview = (items, handle1) => {
@@ -45,15 +44,13 @@ function DragPreview(props) {
45
44
  if (typeof props.ref === "function") props.ref(null);
46
45
  };
47
46
  });
48
- return Show({
49
- get when() {
50
- return isTruthy(preview());
51
- },
52
- get children() {
53
- return _v$ = ssrHydrationKey(), _v$2 = scope(() => {
54
- return escape(preview());
55
- }), ssr(_tmpl$, _v$, ssrStyleProperties("left:", "-100000px", "position:", "fixed", "top:", 0, "z-index:", -100), _v$2);
56
- }
47
+ return memo(() => {
48
+ var _v$, _v$2;
49
+ return memo(() => {
50
+ return !!isTruthy(preview());
51
+ })() ? (_v$ = ssrHydrationKey(), _v$2 = scope(() => {
52
+ return escape(preview());
53
+ }), ssr(_tmpl$, _v$, ssrStyleProperties("left:", "-100000px", "position:", "fixed", "top:", 0, "z-index:", -100), _v$2)) : void 0;
57
54
  });
58
55
  }
59
56
  export { DragPreview };
@@ -1 +1 @@
1
- {"version":3,"file":"drag-preview.js","names":["{preview()}","preview()","<div\n style={{\n left: \"-100000px\",\n position: \"fixed\",\n top: 0,\n \"z-index\": -100,\n }}\n ref={(node) => {\n element = node;\n }}\n >\n {preview()}\n </div>","style={{\n left: \"-100000px\",\n position: \"fixed\",\n top: 0,\n \"z-index\": -100,\n }}","_$ssrHydrationKey","_$scope","_$escape","_$ssr","_$ssrStyleProperties"],"sources":["../../../src/dnd/drag-preview.tsx"],"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/dnd/DragPreview.tsx.\n * Modified for Solid Aria: adapted components, imports, and reactive lifecycle 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 { DragItem, DragPreviewRenderer } from \"@solid2-aria/types-shared\";\nimport { createSignal, flush, onSettled, Show } from \"solid-js\";\nimport type { Element as SolidElement } from \"solid-js\";\n\nimport { isTruthy } from \"../utils/truthy\";\n\nexport interface DragPreviewProps {\n children: (\n items: DragItem[]\n ) => SolidElement | { element: SolidElement; x: number; y: number };\n ref?: (renderer: DragPreviewRenderer | null) => void;\n}\n\nexport function DragPreview(props: DragPreviewProps): SolidElement {\n const [preview, setPreview] = createSignal<SolidElement>(null);\n let element: HTMLDivElement | undefined;\n let frame: number | undefined;\n\n const renderPreview: DragPreviewRenderer = (items, handle1) => {\n const result = props.children(items);\n\n const offset =\n isTruthy(result) && typeof result === \"object\" && \"element\" in result\n ? result\n : null;\n\n setPreview(() => (offset ? offset.element : result));\n flush();\n handle1(element ?? null, offset?.x, offset?.y);\n frame = requestAnimationFrame(() => {\n setPreview(null);\n });\n };\n\n onSettled(() => {\n if (typeof props.ref === \"function\") {\n props.ref(renderPreview);\n }\n\n return () => {\n if (frame !== undefined) {\n cancelAnimationFrame(frame);\n }\n\n if (typeof props.ref === \"function\") {\n props.ref(null);\n }\n };\n });\n\n return (\n <Show when={isTruthy(preview())}>\n <div\n style={{\n left: \"-100000px\",\n position: \"fixed\",\n top: 0,\n \"z-index\": -100,\n }}\n ref={(node) => {\n element = node;\n }}\n >\n {preview()}\n </div>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,YAAY,OAAuC;;CACjE,MAAM,CAAC,SAAS,cAAc,aAA2B,IAAI;CAE7D,IAAI;CAEJ,MAAM,iBAAsC,OAAO,YAAY;EAC7D,MAAM,SAAS,MAAM,SAAS,KAAK;EAEnC,MAAM,SACJ,SAAS,MAAM,KAAK,OAAO,WAAW,YAAY,aAAa,SAC3D,SACA;EAEN,iBAAkB,SAAS,OAAO,UAAU,MAAO;EACnD,MAAM;EACN,QAAmB,MAAM,QAAQ,GAAG,QAAQ,CAAC;EAC7C,QAAQ,4BAA4B;GAClC,WAAW,IAAI;EACjB,CAAC;CACH;CAEA,gBAAgB;EACd,IAAI,OAAO,MAAM,QAAQ,YACvB,MAAM,IAAI,aAAa;EAGzB,aAAa;GACX,IAAI,UAAU,KAAA,GACZ,qBAAqB,KAAK;GAG5B,IAAI,OAAO,MAAM,QAAQ,YACvB,MAAM,IAAI,IAAI;EAElB;CACF,CAAC;CAED,OAAA,KACE;EAAM,IAAA,OAAA;GAAM,OAAA,SAAS,QAAQ,CAAC;EAAC;EAA/B,IAAA,WAAA;GACE,OAAA,MAAAI,gBAYK,GAZL,OAWEJ,YAAAA;IAACC,OAAAA,OAAAA,QAAQ,CAAA;GAAC,CAAA,GAXZC,IAAAA,QAAAA,KACEC,mBAAAA,SACQ,aADR,aAEY,SAFZ,QAGO,GAHP,YAIa,IACZ,GAKDH,IACG;EACD;;AAEV"}
1
+ {"version":3,"file":"drag-preview.js","names":["<Show when={isTruthy(preview())}>\n <div\n style={{\n left: \"-100000px\",\n position: \"fixed\",\n top: 0,\n \"z-index\": -100,\n }}\n ref={(node) => {\n element = node;\n }}\n >\n {preview()}\n </div>\n </Show>","{preview()}","preview()","<div\n style={{\n left: \"-100000px\",\n position: \"fixed\",\n top: 0,\n \"z-index\": -100,\n }}\n ref={(node) => {\n element = node;\n }}\n >\n {preview()}\n </div>","style={{\n left: \"-100000px\",\n position: \"fixed\",\n top: 0,\n \"z-index\": -100,\n }}","_$memo","_$ssrHydrationKey","_$scope","_$escape","_$ssr","_$ssrStyleProperties"],"sources":["../../../src/dnd/drag-preview.tsx"],"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/dnd/DragPreview.tsx.\n * Modified for Solid Aria: adapted components, imports, and reactive lifecycle 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 { DragItem, DragPreviewRenderer } from \"@solid2-aria/types-shared\";\nimport { createSignal, flush, onSettled, Show } from \"solid-js\";\nimport type { Element as SolidElement } from \"solid-js\";\n\nimport { isTruthy } from \"../utils/truthy\";\n\nexport interface DragPreviewProps {\n children: (\n items: DragItem[]\n ) => SolidElement | { element: SolidElement; x: number; y: number };\n ref?: (renderer: DragPreviewRenderer | null) => void;\n}\n\nexport function DragPreview(props: DragPreviewProps): SolidElement {\n const [preview, setPreview] = createSignal<SolidElement>(null);\n let element: HTMLDivElement | undefined;\n let frame: number | undefined;\n\n const renderPreview: DragPreviewRenderer = (items, handle1) => {\n const result = props.children(items);\n\n const offset =\n isTruthy(result) && typeof result === \"object\" && \"element\" in result\n ? result\n : null;\n\n setPreview(() => (offset ? offset.element : result));\n flush();\n handle1(element ?? null, offset?.x, offset?.y);\n frame = requestAnimationFrame(() => {\n setPreview(null);\n });\n };\n\n onSettled(() => {\n if (typeof props.ref === \"function\") {\n props.ref(renderPreview);\n }\n\n return () => {\n if (frame !== undefined) {\n cancelAnimationFrame(frame);\n }\n\n if (typeof props.ref === \"function\") {\n props.ref(null);\n }\n };\n });\n\n return (\n <Show when={isTruthy(preview())}>\n <div\n style={{\n left: \"-100000px\",\n position: \"fixed\",\n top: 0,\n \"z-index\": -100,\n }}\n ref={(node) => {\n element = node;\n }}\n >\n {preview()}\n </div>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,YAAY,OAAuC;CACjE,MAAM,CAAC,SAAS,cAAc,aAA2B,IAAI;CAE7D,IAAI;CAEJ,MAAM,iBAAsC,OAAO,YAAY;EAC7D,MAAM,SAAS,MAAM,SAAS,KAAK;EAEnC,MAAM,SACJ,SAAS,MAAM,KAAK,OAAO,WAAW,YAAY,aAAa,SAC3D,SACA;EAEN,iBAAkB,SAAS,OAAO,UAAU,MAAO;EACnD,MAAM;EACN,QAAmB,MAAM,QAAQ,GAAG,QAAQ,CAAC;EAC7C,QAAQ,4BAA4B;GAClC,WAAW,IAAI;EACjB,CAAC;CACH;CAEA,gBAAgB;EACd,IAAI,OAAO,MAAM,QAAQ,YACvB,MAAM,IAAI,aAAa;EAGzB,aAAa;GACX,IAAI,UAAU,KAAA,GACZ,qBAAqB,KAAK;GAG5B,IAAI,OAAO,MAAM,QAAQ,YACvB,MAAM,IAAI,IAAI;EAElB;CACF,CAAC;CAED,OACEA,WAAAA;;;GAAY,OAAA,CAAA,CAAA,SAAS,QAAQ,CAAC;EAcxB,CAAA,CAAC,CAAD,KAbJ,MAAAM,gBAYK,GAZL,OAWEL,YAAAA;GAACC,OAAAA,OAAAA,QAAQ,CAAA;EAAC,CAAA,GAXZC,IAAAA,QAAAA,KACEC,mBAAAA,SACQ,aADR,aAEY,SAFZ,QAGO,GAHP,YAIa,IACZ,GAKDH,IACG,KAbP,KAAA;CAcM,CAAA;AAEV"}
@@ -17,7 +17,7 @@
17
17
  import { getTruthyValue, isTruthy, whenTruthy } from "../utils/truthy.js";
18
18
  import { isPresent } from "../utils/is-present.js";
19
19
  import { getOwnerDocument, getOwnerWindow } from "../utils/dom-helpers.js";
20
- import { getActiveElement, getEventTarget, nodeContains } from "../utils/shadowdom/dom-functions.js";
20
+ import { getActiveElement, getEventTarget, getParentElement, nodeContains } from "../utils/shadowdom/dom-functions.js";
21
21
  import { focusableElementOrNull, requireElement, requireFocusableElement, requireHTMLInputElement } from "../utils/dom-value.js";
22
22
  import { isFocusable, isTabbable } from "../utils/is-focusable.js";
23
23
  import { requireValue } from "../utils/require-value.js";
@@ -263,7 +263,7 @@ function createFocusManagerForScope(scopeRef) {
263
263
  };
264
264
  }
265
265
  function getScopeRoot(scope) {
266
- return requireValue(requireValue(scope[0], "Expected a present traversal value").parentElement, "Expected scope[0]!.parentElement");
266
+ return requireValue(getParentElement(scope[0]), "Expected scope[0]!.parentElement");
267
267
  }
268
268
  function shouldContainFocus(scopeRef) {
269
269
  let scope = focusScopeTree.getTreeNode(activeScope);
@@ -1 +1 @@
1
- {"version":3,"file":"focus-scope.js","names":["<span\n data-focus-scope-start\n hidden\n ref={(element) => {\n setStartRef(element);\n }}\n />","{content()}","<span\n data-focus-scope-end\n hidden\n ref={(element) => {\n setEndRef(element);\n }}\n />","resolveChildren","_$ssrHydrationKey","_$ssr","_$memo"],"sources":["../../../src/focus/focus-scope.tsx"],"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/focus/FocusScope.tsx.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2; resolve scoped children once under their focus context for rendering and focus tracking.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport type { FocusableElement } from \"@solid2-aria/types-shared\";\nimport {\n createMemo,\n untrack,\n children as resolveChildren,\n createContext,\n onSettled,\n useContext,\n createEffect,\n createSignal,\n} from \"solid-js\";\nimport type { Accessor, Element as SolidElement } from \"solid-js\";\n\nimport { getInteractionModality } from \"../interactions/create-focus-visible\";\nimport { focusSafely } from \"../interactions/focus-safely\";\nimport type { JSX } from \"../types\";\nimport { getOwnerDocument, getOwnerWindow } from \"../utils/dom-helpers\";\nimport {\n focusableElementOrNull,\n requireElement,\n requireFocusableElement,\n requireHTMLInputElement,\n} from \"../utils/dom-value\";\nimport { isFocusable, isTabbable } from \"../utils/is-focusable\";\nimport { isPresent } from \"../utils/is-present\";\nimport { isAndroid, isChrome } from \"../utils/platform\";\nimport { requireValue } from \"../utils/require-value\";\nimport {\n getActiveElement,\n getEventTarget,\n nodeContains,\n} from \"../utils/shadowdom/dom-functions\";\nimport type { ShadowTreeWalker } from \"../utils/shadowdom/shadow-tree-walker\";\nimport { createShadowTreeWalker } from \"../utils/shadowdom/shadow-tree-walker\";\nimport { getTruthyValue, isTruthy, whenTruthy } from \"../utils/truthy\";\n\nclass Tree {\n root: TreeNode;\n private readonly fastMap = new Map<ScopeRef, TreeNode>();\n constructor() {\n this.root = new TreeNode({ scopeRef: null });\n this.fastMap.set(null, this.root);\n }\n get size(): number {\n return this.fastMap.size;\n }\n getTreeNode(data: ScopeRef): TreeNode | undefined {\n return this.fastMap.get(data);\n }\n addTreeNode(\n scopeRef: ScopeRef,\n parent: ScopeRef,\n nodeToRestore?: FocusableElement\n ): void {\n const parentNode = this.fastMap.get(parent ?? null);\n\n if (!parentNode) {\n return;\n }\n\n const node = new TreeNode({ scopeRef });\n parentNode.addChild(node);\n node.parent = parentNode;\n this.fastMap.set(scopeRef, node);\n\n if (nodeToRestore) {\n node.nodeToRestore = nodeToRestore;\n }\n }\n addNode(node: TreeNode): void {\n this.fastMap.set(node.scopeRef, node);\n }\n removeTreeNode(scopeRef: ScopeRef): void {\n // never remove the root\n if (scopeRef === null) {\n return;\n }\n\n const node = this.fastMap.get(scopeRef);\n\n if (!node) {\n return;\n }\n\n const parentNode = node.parent;\n\n // when we remove a scope, check if any sibling scopes are trying to restore focus to something inside the scope we're removing\n // if we are, then replace the siblings restore with the restore from the scope we're removing\n for (const current of this.traverse()) {\n if (\n current !== node &&\n node.nodeToRestore &&\n current.nodeToRestore &&\n node.scopeRef &&\n node.scopeRef() &&\n isElementInScope(current.nodeToRestore, node.scopeRef())\n ) {\n current.nodeToRestore = node.nodeToRestore;\n }\n }\n\n const { children } = node;\n\n if (parentNode) {\n // oxlint-disable-next-line unicorn/prefer-dom-node-remove -- Collection and focus-tree nodes implement their own parent/child protocol.\n parentNode.removeChild(node);\n\n if (children.size > 0) {\n for (const child of children) {\n whenTruthy(parentNode, (truthyValue0) => {\n truthyValue0.addChild(child);\n });\n }\n }\n }\n\n this.fastMap.delete(node.scopeRef);\n }\n // Pre Order Depth First\n *traverse(node: TreeNode = this.root): Generator<TreeNode> {\n if (isPresent(node.scopeRef)) {\n yield node;\n }\n\n if (node.children.size > 0) {\n for (const child of node.children) {\n yield* this.traverse(child);\n }\n }\n }\n clone(): Tree {\n const newTree = new Tree();\n\n for (const node of this.traverse()) {\n newTree.addTreeNode(\n node.scopeRef,\n node.parent?.scopeRef ?? null,\n node.nodeToRestore\n );\n }\n\n return newTree;\n }\n}\n\nclass TreeNode {\n public scopeRef: ScopeRef;\n public nodeToRestore?: FocusableElement;\n public parent?: TreeNode;\n public children = new Set<TreeNode>();\n public contain = false;\n constructor(props: { scopeRef: ScopeRef }) {\n this.scopeRef = untrack(() => props.scopeRef);\n }\n addChild(node: TreeNode): void {\n this.children.add(node);\n node.parent = this;\n }\n removeChild(node: TreeNode): void {\n this.children.delete(node);\n node.parent = undefined;\n }\n}\n\nexport const focusScopeTree: Tree = new Tree();\n\nexport interface FocusScopeProps {\n /** The contents of the focus scope. */\n children: SolidElement;\n /**\n * Whether to contain focus inside the scope, so users cannot\n * move focus outside, for example in a modal dialog.\n */\n contain?: boolean;\n /**\n * Whether to restore focus back to the element that was focused\n * when the focus scope mounted, after the focus scope unmounts.\n */\n restoreFocus?: boolean;\n /** Whether to auto focus the first focusable element in the focus scope on mount. */\n autoFocus?: boolean;\n}\n\nexport interface FocusManagerOptions {\n /** The element to start searching from. The currently focused element by default. */\n from?: Element;\n /** Whether to only include tabbable elements, or all focusable elements. */\n tabbable?: boolean;\n /** Whether focus should wrap around when it reaches the end of the scope. */\n wrap?: boolean;\n /** A callback that determines whether the given element is focused. */\n accept?: (node: Element) => boolean;\n}\n\nexport interface FocusManager {\n /** Moves focus to the next focusable or tabbable element in the focus scope. */\n focusNext: (opts?: FocusManagerOptions) => FocusableElement | null;\n /** Moves focus to the previous focusable or tabbable element in the focus scope. */\n focusPrevious: (opts?: FocusManagerOptions) => FocusableElement | null;\n /** Moves focus to the first focusable or tabbable element in the focus scope. */\n focusFirst: (opts?: FocusManagerOptions) => FocusableElement | null;\n /** Moves focus to the last focusable or tabbable element in the focus scope. */\n focusLast: (opts?: FocusManagerOptions) => FocusableElement | null;\n}\n\ntype ScopeRef = Accessor<Element[] | null> | null;\n\ninterface IFocusContext {\n focusManager: FocusManager;\n parentNode: TreeNode | null;\n}\n\nconst FocusContext = createContext<IFocusContext | null>(null);\nconst RESTORE_FOCUS_EVENT = \"react-aria-focus-scope-restore\";\nlet activeScope: ScopeRef = null;\n\n/**\n * A FocusScope manages focus for its descendants. It supports containing focus inside\n * the scope, restoring focus to the previously focused element on unmount, and auto\n * focusing children on mount. It also acts as a container for a programmatic focus\n * management interface that can be used to move focus forward and back in response\n * to user events.\n */\nconst stopPropagation = (event: Event) => {\n event.stopPropagation();\n};\n\nexport function FocusScope(props: FocusScopeProps): JSX.Element {\n const [startRef, setStartRef] = createSignal<HTMLSpanElement | null>(null, {\n ownedWrite: true,\n });\n\n const [endRef, setEndRef] = createSignal<HTMLSpanElement | null>(null, {\n ownedWrite: true,\n });\n\n const [scopeRef, setScopeRef] = createSignal<Element[]>([], {\n ownedWrite: true,\n });\n\n const parentNode = useContext(FocusContext)?.parentNode;\n const node = new TreeNode({ scopeRef });\n const focusManager = createFocusManagerForScope(scopeRef);\n const value = { focusManager, parentNode: node };\n\n const content = resolveChildren(() => (\n <FocusContext value={value}>{props.children}</FocusContext>\n ));\n\n onSettled(() => {\n let parent = getTruthyValue(parentNode) ?? focusScopeTree.root;\n\n if (\n focusScopeTree.getTreeNode(parent.scopeRef) &&\n activeScope &&\n !isAncestorScope(activeScope, parent.scopeRef)\n ) {\n parent = focusScopeTree.getTreeNode(activeScope) ?? parent;\n }\n\n parent.addChild(node);\n focusScopeTree.addNode(node);\n\n return () => {\n const parentScope =\n focusScopeTree.getTreeNode(scopeRef)?.parent?.scopeRef ?? null;\n\n if (\n (scopeRef === activeScope || isAncestorScope(scopeRef, activeScope)) &&\n (!parentScope || focusScopeTree.getTreeNode(parentScope))\n ) {\n activeScope = parentScope;\n }\n\n focusScopeTree.removeTreeNode(scopeRef);\n };\n });\n createEffect(\n () => props.contain,\n (contain) => {\n node.contain = isTruthy(contain);\n },\n { ssrSource: \"client\" }\n );\n\n createEffect(\n () => ({ content: content(), end: endRef(), start: startRef() }),\n ({ start, end }): undefined | (() => void) => {\n if (!start || !end) {\n return undefined;\n }\n\n let element = start.nextSibling;\n const nodes: Element[] = [];\n\n while (element && element !== end) {\n if (element instanceof Element) {\n nodes.push(element);\n element.addEventListener(RESTORE_FOCUS_EVENT, stopPropagation);\n }\n\n element = element.nextSibling;\n }\n\n setScopeRef(nodes);\n\n return () => {\n for (const elementValue of nodes) {\n elementValue.removeEventListener(\n RESTORE_FOCUS_EVENT,\n stopPropagation\n );\n }\n };\n },\n { ssrSource: \"client\" }\n );\n createActiveScopeTracker(\n scopeRef,\n () => props.restoreFocus,\n () => props.contain\n );\n createFocusContainment(scopeRef, () => props.contain);\n createRestoreFocus(\n scopeRef,\n () => props.restoreFocus,\n () => props.contain\n );\n createAutoFocus(scopeRef, () => props.autoFocus);\n createEffect(\n scopeRef,\n (scopeNodes) => {\n const activeElement = getActiveElement(getOwnerDocument(scopeNodes[0]));\n\n if (isElementInScope(activeElement, scopeNodes)) {\n let scope: TreeNode | null = null;\n\n for (const child of focusScopeTree.traverse()) {\n if (\n child.scopeRef &&\n isElementInScope(activeElement, untrack(child.scopeRef))\n ) {\n scope = child;\n }\n }\n\n if (scope && scope === focusScopeTree.getTreeNode(scopeRef)) {\n activeScope = scope.scopeRef;\n }\n }\n },\n { ssrSource: \"client\" }\n );\n\n return (\n <>\n <span\n data-focus-scope-start\n hidden\n ref={(element) => {\n setStartRef(element);\n }}\n />\n {content()}\n <span\n data-focus-scope-end\n hidden\n ref={(element) => {\n setEndRef(element);\n }}\n />\n </>\n );\n}\n\n/**\n * Returns a FocusManager interface for the parent FocusScope.\n * A FocusManager can be used to programmatically move focus within\n * a FocusScope, e.g. in response to user events like keyboard navigation.\n */\nexport function createFocusScopeManager(): FocusManager | undefined {\n return useContext(FocusContext)?.focusManager;\n}\n\nfunction createFocusManagerForScope(\n scopeRef: Accessor<Element[] | null>\n): FocusManager {\n return {\n focusFirst(opts = {}) {\n const scope = requireValue(scopeRef(), \"Expected focus scope nodes\");\n const { tabbable, accept } = opts;\n const scopeRoot = getScopeRoot(scope);\n\n const walker = getFocusableTreeWalker(\n scopeRoot,\n { accept, tabbable },\n scope\n );\n\n walker.currentNode = requireValue(\n requireValue(scope[0], \"Expected a present traversal value\")\n .previousElementSibling,\n \"Expected scope[0]!.previousElementSibling\"\n );\n const nextNode = focusableElementOrNull(walker.nextNode());\n\n if (isTruthy(nextNode)) {\n focusElement(nextNode, true);\n }\n\n return nextNode;\n },\n focusLast(opts = {}) {\n const scope = requireValue(scopeRef(), \"Expected focus scope nodes\");\n const { tabbable, accept } = opts;\n const scopeRoot = getScopeRoot(scope);\n\n const walker = getFocusableTreeWalker(\n scopeRoot,\n { accept, tabbable },\n scope\n );\n\n walker.currentNode = requireValue(\n requireValue(scope.at(-1), \"Expected a present traversal value\")\n .nextElementSibling,\n \"Expected scope.at(-1)!.nextElementSibling\"\n );\n const previousNode = focusableElementOrNull(walker.previousNode());\n\n if (isTruthy(previousNode)) {\n focusElement(previousNode, true);\n }\n\n return previousNode;\n },\n focusNext(opts: FocusManagerOptions = {}) {\n const scope = requireValue(scopeRef(), \"Expected focus scope nodes\");\n const { from, tabbable, wrap, accept } = opts;\n\n const node =\n getTruthyValue(from) ??\n requireValue(\n getActiveElement(getOwnerDocument(scope[0] ?? undefined)),\n \"Expected getActiveElement(getOwnerDocument(scope[0]! ?? undefined))\"\n );\n\n const sentinel = requireValue(\n requireValue(scope[0], \"Expected a present traversal value\")\n .previousElementSibling,\n \"Expected scope[0]!.previousElementSibling\"\n );\n\n const scopeRoot = getScopeRoot(scope);\n\n const walker = getFocusableTreeWalker(\n scopeRoot,\n { accept, tabbable },\n scope\n );\n\n walker.currentNode = isElementInScope(node, scope) ? node : sentinel;\n let nextNode = focusableElementOrNull(walker.nextNode());\n\n if (!isTruthy(nextNode) && isTruthy(wrap)) {\n walker.currentNode = sentinel;\n nextNode = focusableElementOrNull(walker.nextNode());\n }\n\n if (isTruthy(nextNode)) {\n focusElement(nextNode, true);\n }\n\n return nextNode;\n },\n focusPrevious(opts: FocusManagerOptions = {}) {\n const scope = requireValue(scopeRef(), \"Expected focus scope nodes\");\n const { from, tabbable, wrap, accept } = opts;\n\n const node =\n getTruthyValue(from) ??\n requireValue(\n getActiveElement(getOwnerDocument(scope[0] ?? undefined)),\n \"Expected getActiveElement(getOwnerDocument(scope[0]! ?? undefined))\"\n );\n\n const sentinel = requireValue(\n requireValue(scope.at(-1), \"Expected a present traversal value\")\n .nextElementSibling,\n \"Expected scope[scope.length - 1]!.nextElementSibling\"\n );\n\n const scopeRoot = getScopeRoot(scope);\n\n const walker = getFocusableTreeWalker(\n scopeRoot,\n { accept, tabbable },\n scope\n );\n\n walker.currentNode = isElementInScope(node, scope) ? node : sentinel;\n let previousNode = focusableElementOrNull(walker.previousNode());\n\n if (!isTruthy(previousNode) && isTruthy(wrap)) {\n walker.currentNode = sentinel;\n previousNode = focusableElementOrNull(walker.previousNode());\n }\n\n if (isTruthy(previousNode)) {\n focusElement(previousNode, true);\n }\n\n return previousNode;\n },\n };\n}\n\nfunction getScopeRoot(scope: Element[]) {\n return requireValue(\n requireValue(scope[0], \"Expected a present traversal value\").parentElement,\n \"Expected scope[0]!.parentElement\"\n );\n}\n\nfunction shouldContainFocus(scopeRef: ScopeRef) {\n let scope = focusScopeTree.getTreeNode(activeScope);\n\n while (scope && scope.scopeRef !== scopeRef) {\n if (scope.contain) {\n return false;\n }\n\n scope = scope.parent;\n }\n\n return true;\n}\n\nfunction getRadiosInGroup(element: HTMLInputElement): HTMLInputElement[] {\n if (!element.form) {\n // Radio buttons outside a form - query the document\n return [\n ...getOwnerDocument(element).querySelectorAll<HTMLInputElement>(\n `input[type=\"radio\"][name=\"${CSS.escape(element.name)}\"]`\n ),\n ].filter((radio) => !radio.form);\n }\n\n // namedItem returns RadioNodeList (iterable) for 2+ elements, but a single Element for exactly 1.\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormControlsCollection/namedItem\n const radioList = element.form.elements.namedItem(element.name);\n const ownerWindow = getOwnerWindow(element);\n\n if (radioList instanceof ownerWindow.RadioNodeList) {\n return [...radioList].filter(\n (el): el is HTMLInputElement => el instanceof ownerWindow.HTMLInputElement\n );\n }\n\n if (radioList instanceof ownerWindow.HTMLInputElement) {\n return [radioList];\n }\n\n return [];\n}\n\nfunction isTabbableRadio(element: HTMLInputElement): boolean {\n if (element.checked) {\n return true;\n }\n\n const radios = getRadiosInGroup(element);\n\n return radios.length > 0 && !radios.some((radio) => radio.checked);\n}\n\nfunction createFocusContainment(\n scopeRef: Accessor<Element[] | null>,\n contain: () => boolean | undefined\n) {\n let focusedNode: FocusableElement | undefined;\n\n let raf: ReturnType<typeof requestAnimationFrame> | undefined;\n\n createEffect(\n () => ({ contain: contain(), scope: scopeRef() }),\n ({ scope, contain: shouldContain }): undefined | (() => void) => {\n if (scope === null || scope.length === 0) {\n return undefined;\n }\n\n if (!isTruthy(shouldContain)) {\n // if contain() was changed, then we should cancel any ongoing waits to pull focus back into containment\n if (raf !== undefined) {\n cancelAnimationFrame(raf);\n raf = undefined;\n }\n\n return undefined;\n }\n\n const ownerDocument = getOwnerDocument(\n requireValue(scope[0], \"Expected first scope element\")\n );\n\n // Handle the Tab key to contain() focus within the scope\n const onKeyDown = (e: KeyboardEvent) => {\n if (!isRestoreFocusTab(e, scopeRef)) {\n return;\n }\n\n const focusedElement = getActiveElement(ownerDocument);\n const scopeValue = scopeRef();\n\n if (!scopeValue || !isElementInScope(focusedElement, scopeValue)) {\n return;\n }\n\n const scopeRoot = getScopeRoot(scopeValue);\n\n const walker = getFocusableTreeWalker(\n scopeRoot,\n { tabbable: true },\n scopeValue\n );\n\n if (!focusedElement) {\n return;\n }\n\n walker.currentNode = focusedElement;\n\n let nextElement = focusableElementOrNull(\n e.shiftKey ? walker.previousNode() : walker.nextNode()\n );\n\n if (!isTruthy(nextElement)) {\n walker.currentNode = e.shiftKey\n ? requireValue(\n requireValue(\n scopeValue.at(-1),\n \"Expected a present traversal value\"\n ).nextElementSibling,\n \"Expected scope.at(-1)!.nextElementSibling\"\n )\n : requireValue(\n requireValue(\n scopeValue[0],\n \"Expected a present traversal value\"\n ).previousElementSibling,\n \"Expected scope[0]!.previousElementSibling\"\n );\n nextElement = focusableElementOrNull(\n e.shiftKey ? walker.previousNode() : walker.nextNode()\n );\n }\n\n e.preventDefault();\n\n if (isTruthy(nextElement)) {\n focusElement(nextElement, true);\n\n if (\n nextElement instanceof getOwnerWindow(nextElement).HTMLInputElement\n ) {\n nextElement.select();\n }\n }\n };\n\n const onFocus: EventListener = (e) => {\n // If focusing an element in a child scope of the currently active scope, the child becomes active.\n // Moving out of the active scope to an ancestor is not allowed.\n if (\n (!activeScope || isAncestorScope(activeScope, scopeRef)) &&\n isElementInScope(requireElement(getEventTarget(e)), scope)\n ) {\n activeScope = scopeRef;\n focusedNode = requireFocusableElement(getEventTarget(e));\n } else if (\n shouldContainFocus(scopeRef) &&\n !isElementInChildScope(requireElement(getEventTarget(e)), scopeRef)\n ) {\n // If a focus event occurs outside the active scope (e.g. user tabs from browser location bar),\n // restore focus to the previously focused node or the first tabbable element in the active scope.\n if (focusedNode) {\n focusElement(focusedNode);\n } else {\n const activeNodes = activeScope?.();\n\n if (activeNodes) {\n focusFirstInScope(activeNodes);\n }\n }\n } else if (shouldContainFocus(scopeRef)) {\n focusedNode = requireFocusableElement(getEventTarget(e));\n }\n };\n\n const onBlur: EventListener = (e) => {\n // Firefox doesn't shift focus back to the Dialog properly without this\n if (raf !== undefined) {\n cancelAnimationFrame(raf);\n }\n\n raf = requestAnimationFrame(() => {\n // Patches infinite focus coersion loop for Android Talkback where the user isn't able to move the virtual cursor\n // if within a containing focus scope. Bug filed against Chrome: https://issuetracker.google.com/issues/384844019.\n // Note that this means focus can leave focus containing modals due to this, but it is isolated to Chrome Talkback.\n const modality = getInteractionModality();\n\n const shouldSkipFocusRestore =\n (modality === \"virtual\" || modality === null) &&\n isAndroid() &&\n isChrome();\n\n // Use document.activeElement instead of e.relatedTarget so we can tell if user clicked into iframe\n const activeElement = getActiveElement(ownerDocument);\n\n if (\n !shouldSkipFocusRestore &&\n activeElement &&\n shouldContainFocus(scopeRef) &&\n !isElementInChildScope(activeElement, scopeRef)\n ) {\n activeScope = scopeRef;\n const target = requireFocusableElement(getEventTarget(e));\n\n if (isTruthy(target) && target.isConnected) {\n focusedNode = target;\n focusElement(focusedNode);\n } else {\n const activeNodes = activeScope();\n\n if (activeNodes) {\n focusFirstInScope(activeNodes);\n }\n }\n }\n });\n };\n\n ownerDocument.addEventListener(\"keydown\", onKeyDown, false);\n ownerDocument.addEventListener(\"focusin\", onFocus, false);\n\n for (const element of scope ?? []) {\n element.addEventListener(\"focusin\", onFocus, false);\n }\n\n for (const element of scope ?? []) {\n element.addEventListener(\"focusout\", onBlur, false);\n }\n\n return () => {\n ownerDocument.removeEventListener(\"keydown\", onKeyDown, false);\n ownerDocument.removeEventListener(\"focusin\", onFocus, false);\n\n for (const element of scope ?? []) {\n element.removeEventListener(\"focusin\", onFocus, false);\n }\n\n for (const element of scope ?? []) {\n element.removeEventListener(\"focusout\", onBlur, false);\n }\n };\n },\n { ssrSource: \"client\" }\n );\n onSettled(() => () => {\n if (raf !== undefined) {\n cancelAnimationFrame(raf);\n }\n });\n}\n\nfunction isElementInAnyScope(element: Element) {\n return isElementInChildScope(element);\n}\n\nfunction isElementInScope(element?: Element | null, scope?: Element[] | null) {\n if (!element) {\n return false;\n }\n\n if (!scope) {\n return false;\n }\n\n return scope.some((node) => nodeContains(node, element));\n}\n\nfunction isElementInChildScope(element: Element, scope: ScopeRef = null) {\n // If the element is within a top layer element (e.g. toasts), always allow moving focus there.\n if (\n element instanceof Element &&\n element.closest(\"[data-react-aria-top-layer]\")\n ) {\n return true;\n }\n\n // node.contains in isElementInScope covers child scopes that are also DOM children,\n // but does not cover child scopes in portals.\n for (const { scopeRef: s } of focusScopeTree.traverse(\n focusScopeTree.getTreeNode(scope)\n )) {\n if (s && isElementInScope(element, untrack(s))) {\n return true;\n }\n }\n\n return false;\n}\n\n/** @private */\nexport function isElementInChildOfActiveScope(element: Element): boolean {\n return isElementInChildScope(element, activeScope);\n}\n\nfunction isAncestorScope(ancestor: ScopeRef, scope: ScopeRef) {\n let parent = focusScopeTree.getTreeNode(scope)?.parent;\n\n while (parent) {\n if (parent.scopeRef === ancestor) {\n return true;\n }\n\n ({ parent } = parent);\n }\n\n return false;\n}\n\nfunction focusElement(element: FocusableElement | null, scroll = false) {\n if (isPresent(element) && !scroll) {\n try {\n focusSafely(element);\n } catch {\n // ignore\n }\n } else if (isPresent(element)) {\n try {\n element.focus();\n } catch {\n // ignore\n }\n }\n}\n\nfunction getFirstInScope(\n scope: Element[],\n tabbable = true\n): FocusableElement | null {\n const sentinel = requireValue(\n requireValue(scope[0], \"Expected a present traversal value\")\n .previousElementSibling,\n \"Expected scope[0]!.previousElementSibling\"\n );\n\n let scopeRoot = getScopeRoot(scope);\n let walker = getFocusableTreeWalker(scopeRoot, { tabbable }, scope);\n walker.currentNode = sentinel;\n let nextNode = walker.nextNode();\n\n // If the scope does not contain a tabbable element, use the first focusable element.\n if (tabbable && !nextNode) {\n scopeRoot = getScopeRoot(scope);\n walker = getFocusableTreeWalker(scopeRoot, { tabbable: false }, scope);\n walker.currentNode = sentinel;\n nextNode = walker.nextNode();\n }\n\n // TreeWalker.nextNode() returns null when the scope contains no focusable element.\n return focusableElementOrNull(nextNode);\n}\n\nfunction focusFirstInScope(scope: Element[], tabbable = true) {\n focusElement(getFirstInScope(scope, tabbable));\n}\n\nfunction createAutoFocus(\n scopeRef: Accessor<Element[] | null>,\n autoFocus: () => boolean | undefined\n) {\n let pendingAutoFocus = untrack(autoFocus);\n createEffect(\n scopeRef,\n (scope) => {\n if (!isTruthy(pendingAutoFocus) || scope === null || scope.length === 0) {\n return;\n }\n\n pendingAutoFocus = false;\n activeScope = scopeRef;\n const ownerDocument = getOwnerDocument(scope[0]);\n\n if (!isElementInScope(getActiveElement(ownerDocument), scope)) {\n focusFirstInScope(scope);\n }\n },\n { ssrSource: \"client\" }\n );\n}\n\nfunction createActiveScopeTracker(\n scopeRef: Accessor<Element[] | null>,\n restore: () => boolean | undefined,\n contain: () => boolean | undefined\n) {\n // Track active scopes that do not contain or restore focus.\n createEffect(\n () => ({ contain: contain(), restore: restore(), scope: scopeRef() }),\n ({\n scope,\n restore: shouldRestore,\n contain: shouldContain,\n }): undefined | (() => void) => {\n if (\n scope === null ||\n scope.length === 0 ||\n isTruthy(shouldRestore) ||\n isTruthy(shouldContain)\n ) {\n return undefined;\n }\n\n const ownerDocument = getOwnerDocument(\n requireValue(scope[0], \"Expected first scope element\")\n );\n\n const onFocus = (e: Event) => {\n const target = requireElement(getEventTarget(e));\n\n if (isElementInScope(target, scope)) {\n activeScope = scopeRef;\n } else if (!isElementInAnyScope(target)) {\n activeScope = null;\n }\n };\n\n ownerDocument.addEventListener(\"focusin\", onFocus, false);\n\n for (const element of scope ?? []) {\n element.addEventListener(\"focusin\", onFocus, false);\n }\n\n return () => {\n ownerDocument.removeEventListener(\"focusin\", onFocus, false);\n\n for (const element of scope ?? []) {\n element.removeEventListener(\"focusin\", onFocus, false);\n }\n };\n },\n { ssrSource: \"client\" }\n );\n}\n\nfunction shouldRestoreFocus(scopeRef: ScopeRef) {\n let scope = focusScopeTree.getTreeNode(activeScope);\n\n while (scope && scope.scopeRef !== scopeRef) {\n if (scope.nodeToRestore) {\n return false;\n }\n\n scope = scope.parent;\n }\n\n return scope?.scopeRef === scopeRef;\n}\n\nfunction createRestoreFocus(\n scopeRef: Accessor<Element[] | null>,\n restoreFocus: () => boolean | undefined,\n contain: () => boolean | undefined\n) {\n // Capture focus before scoped children can autofocus.\n const initialFocusTarget = untrack(() =>\n typeof document === \"undefined\"\n ? null\n : focusableElementOrNull(\n getActiveElement(getOwnerDocument(scopeRef()?.[0]))\n )\n );\n\n const scopeReady = createMemo(() => (scopeRef()?.length ?? 0) > 0);\n\n // restoring scopes should all track if they are active regardless of contain(), but contain() already tracks it plus logic to contain() the focus\n // restoring-non-containing scopes should only care if they become active so they can perform the restore\n createEffect(\n () => ({ contain: contain(), restore: restoreFocus(), scope: scopeRef() }),\n ({\n scope,\n restore: shouldRestore,\n contain: shouldContain,\n }): undefined | (() => void) => {\n if (scope === null || scope.length === 0) {\n return undefined;\n }\n\n const ownerDocument = getOwnerDocument(\n requireValue(scope[0], \"Expected first scope element\")\n );\n\n if (!isTruthy(shouldRestore) || isTruthy(shouldContain)) {\n return undefined;\n }\n\n const onFocus = () => {\n // If focusing an element in a child scope of the currently active scope, the child becomes active.\n // Moving out of the active scope to an ancestor is not allowed.\n if (\n (!activeScope || isAncestorScope(activeScope, scopeRef)) &&\n isElementInScope(getActiveElement(ownerDocument), scope)\n ) {\n activeScope = scopeRef;\n }\n };\n\n ownerDocument.addEventListener(\"focusin\", onFocus, false);\n\n for (const element of scope ?? []) {\n element.addEventListener(\"focusin\", onFocus, false);\n }\n\n return () => {\n ownerDocument.removeEventListener(\"focusin\", onFocus, false);\n\n for (const element of scope ?? []) {\n element.removeEventListener(\"focusin\", onFocus, false);\n }\n };\n },\n { ssrSource: \"client\" }\n );\n createEffect(\n () => ({ contain: contain(), restore: restoreFocus(), scope: scopeRef() }),\n ({\n scope,\n restore: shouldRestore,\n contain: shouldContain,\n }): undefined | (() => void) => {\n if (scope === null || scope.length === 0) {\n return undefined;\n }\n\n const ownerDocument = getOwnerDocument(scope[0]);\n\n if (!isTruthy(shouldRestore)) {\n return undefined;\n }\n\n // Handle the Tab key so that tabbing out of the scope goes to the next element\n // after the node that had focus when the scope mounted. This is important when\n // using portals for overlays, so that focus goes to the expected element when\n // tabbing out of the overlay.\n const onKeyDown = (e: KeyboardEvent) => {\n if (!isRestoreFocusTab(e, scopeRef)) {\n return;\n }\n\n const focusedElement = focusableElementOrNull(\n ownerDocument.activeElement\n );\n\n if (\n focusedElement === null ||\n !isElementInChildScope(focusedElement, scopeRef) ||\n !shouldRestoreFocus(scopeRef)\n ) {\n return;\n }\n\n const treeNode = focusScopeTree.getTreeNode(scopeRef);\n\n if (!treeNode) {\n return;\n }\n\n let { nodeToRestore } = treeNode;\n\n // Create a DOM tree walker that matches all tabbable elements\n const walker = getFocusableTreeWalker(ownerDocument.body, {\n tabbable: true,\n });\n\n // Find the next tabbable element after the currently focused element\n walker.currentNode = focusedElement;\n\n let nextElement = focusableElementOrNull(\n e.shiftKey ? walker.previousNode() : walker.nextNode()\n );\n\n if (\n !nodeToRestore ||\n !nodeToRestore.isConnected ||\n nodeToRestore === ownerDocument.body\n ) {\n nodeToRestore = undefined;\n treeNode.nodeToRestore = undefined;\n }\n\n // If there is no next element, or it is outside the current scope, move focus to the\n // next element after the node to restore to instead.\n if (\n (!isTruthy(nextElement) ||\n !isElementInChildScope(nextElement, scopeRef)) &&\n nodeToRestore\n ) {\n walker.currentNode = nodeToRestore;\n\n // Skip over elements within the scope, in case the scope immediately follows the node to restore.\n do {\n nextElement = focusableElementOrNull(\n e.shiftKey ? walker.previousNode() : walker.nextNode()\n );\n } while (\n nextElement !== null &&\n isElementInChildScope(nextElement, scopeRef)\n );\n\n e.preventDefault();\n e.stopPropagation();\n\n if (isTruthy(nextElement)) {\n focusElement(nextElement, true);\n } else if (isElementInAnyScope(nodeToRestore)) {\n focusElement(nodeToRestore, true);\n } else {\n focusedElement.blur();\n }\n }\n };\n\n if (!isTruthy(shouldContain)) {\n ownerDocument.addEventListener(\"keydown\", onKeyDown, true);\n }\n\n return () => {\n if (!isTruthy(shouldContain)) {\n ownerDocument.removeEventListener(\"keydown\", onKeyDown, true);\n }\n };\n },\n { ssrSource: \"client\" }\n );\n createEffect(\n () => ({ ready: scopeReady(), restore: restoreFocus() }),\n ({ ready, restore: shouldRestore }): undefined | (() => void) => {\n if (!ready || !isTruthy(shouldRestore)) {\n return undefined;\n }\n\n const ownerDocument = getOwnerDocument(untrack(scopeRef)?.[0]);\n\n if (!isTruthy(shouldRestore)) {\n return undefined;\n }\n\n const treeNode = focusScopeTree.getTreeNode(scopeRef);\n\n if (!treeNode) {\n return undefined;\n }\n\n treeNode.nodeToRestore = initialFocusTarget ?? undefined;\n\n return () => {\n const treeNodeValue = focusScopeTree.getTreeNode(scopeRef);\n\n if (!treeNodeValue) {\n return;\n }\n\n const { nodeToRestore } = treeNodeValue;\n // if we already lost focus to the body and this was the active scope, then we should attempt to restore\n const activeElement = getActiveElement(ownerDocument);\n\n if (\n isTruthy(untrack(restoreFocus)) &&\n nodeToRestore &&\n ((activeElement && isElementInChildScope(activeElement, scopeRef)) ||\n (activeElement === ownerDocument.body &&\n shouldRestoreFocus(scopeRef)))\n ) {\n // freeze the focusScopeTree so it persists after the raf, otherwise during unmount nodes are removed from it\n const clonedTree = focusScopeTree.clone();\n requestAnimationFrame(() => {\n // Only restore focus if we've lost focus to the body, the alternative is that focus has been purposefully moved elsewhere\n if (ownerDocument.activeElement === ownerDocument.body) {\n // look up the tree starting with our scope to find a nodeToRestore still in the DOM\n let treeNodeValue2 = clonedTree.getTreeNode(scopeRef);\n\n while (treeNodeValue2) {\n if (\n treeNodeValue2.nodeToRestore &&\n treeNodeValue2.nodeToRestore.isConnected\n ) {\n restoreFocusToElement(treeNodeValue2.nodeToRestore);\n\n return;\n }\n\n treeNodeValue2 = treeNodeValue2.parent;\n }\n\n // If no nodeToRestore was found, focus the first element in the nearest\n // ancestor scope that is still in the tree.\n treeNodeValue2 = clonedTree.getTreeNode(scopeRef);\n\n while (treeNodeValue2) {\n const scopeNodes = treeNodeValue2.scopeRef?.();\n\n if (\n scopeNodes &&\n focusScopeTree.getTreeNode(treeNodeValue2.scopeRef)\n ) {\n const node = getFirstInScope(scopeNodes, true);\n\n // The scope may have nothing focusable in it, e.g. if its focusable\n // content was removed or hidden. Keep walking up in that case.\n if (node) {\n restoreFocusToElement(node);\n\n return;\n }\n }\n\n treeNodeValue2 = treeNodeValue2.parent;\n }\n }\n });\n }\n };\n },\n { ssrSource: \"client\" }\n );\n}\n\nfunction restoreFocusToElement(node: FocusableElement) {\n // Dispatch a custom event that parent elements can intercept to customize focus restoration.\n // For example, virtualized collection components reuse DOM elements, so the original element\n // might still exist in the DOM but representing a different item.\n if (\n node.dispatchEvent(\n new CustomEvent(RESTORE_FOCUS_EVENT, { bubbles: true, cancelable: true })\n )\n ) {\n focusElement(node);\n }\n}\n\n/**\n * Create a [TreeWalker]{@link https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker}\n * that matches all focusable/tabbable elements.\n */\nexport function getFocusableTreeWalker(\n root: Element,\n opts?: FocusManagerOptions,\n scope?: Element[]\n): ShadowTreeWalker | TreeWalker {\n const filter = isTruthy(opts?.tabbable) ? isTabbable : isFocusable;\n // Ensure that root is an Element or fall back appropriately\n const rootElement = root?.nodeType === Node.ELEMENT_NODE ? root : null;\n // Determine the document to use\n const doc = getOwnerDocument(rootElement);\n\n // Create a TreeWalker, ensuring the root is an Element or Document\n const walker = createShadowTreeWalker(\n doc,\n getTruthyValue(root) ?? doc,\n NodeFilter.SHOW_ELEMENT,\n {\n acceptNode(node) {\n // Skip nodes inside the starting node.\n if (nodeContains(opts?.from, node)) {\n return NodeFilter.FILTER_REJECT;\n }\n\n if (\n isTruthy(opts?.tabbable) &&\n requireElement(node).tagName === \"INPUT\" &&\n requireHTMLInputElement(node).getAttribute(\"type\") === \"radio\"\n ) {\n // If the radio is in a form, we can get all the other radios by name\n if (!isTabbableRadio(requireHTMLInputElement(node))) {\n return NodeFilter.FILTER_REJECT;\n }\n\n // If the radio is in the same group as the current node and none are selected, we can skip it\n if (\n requireElement(walker.currentNode).tagName === \"INPUT\" &&\n requireHTMLInputElement(walker.currentNode).type === \"radio\" &&\n requireHTMLInputElement(walker.currentNode).name ===\n requireHTMLInputElement(node).name\n ) {\n return NodeFilter.FILTER_REJECT;\n }\n }\n\n if (\n filter(requireElement(node)) &&\n (!scope || isElementInScope(requireElement(node), scope)) &&\n (!opts?.accept || opts.accept(requireElement(node)))\n ) {\n return NodeFilter.FILTER_ACCEPT;\n }\n\n return NodeFilter.FILTER_SKIP;\n },\n }\n );\n\n if (opts?.from) {\n walker.currentNode = opts.from;\n }\n\n return walker;\n}\n\n/**\n * Creates a FocusManager object that can be used to move focus within an element.\n */\nexport function createFocusManager(\n ref: Accessor<Element | null>,\n defaultOptions: FocusManagerOptions = {}\n): FocusManager {\n return {\n focusFirst(opts = defaultOptions) {\n const root = ref();\n\n if (!root) {\n return null;\n }\n\n const {\n tabbable = defaultOptions.tabbable,\n accept = defaultOptions.accept,\n } = opts;\n\n const walker = getFocusableTreeWalker(root, { accept, tabbable });\n const nextNode = focusableElementOrNull(walker.nextNode());\n\n if (isTruthy(nextNode)) {\n focusElement(nextNode, true);\n }\n\n return nextNode;\n },\n focusLast(opts = defaultOptions) {\n const root = ref();\n\n if (!root) {\n return null;\n }\n\n const {\n tabbable = defaultOptions.tabbable,\n accept = defaultOptions.accept,\n } = opts;\n\n const walker = getFocusableTreeWalker(root, { accept, tabbable });\n const next = last(walker);\n\n if (next) {\n focusElement(next, true);\n }\n\n return next ?? null;\n },\n focusNext(opts: FocusManagerOptions = {}) {\n const root = ref();\n\n if (!root) {\n return null;\n }\n\n const {\n from,\n tabbable = defaultOptions.tabbable,\n wrap = defaultOptions.wrap,\n accept = defaultOptions.accept,\n } = opts;\n\n const node =\n getTruthyValue(from) ?? getActiveElement(getOwnerDocument(root));\n\n const walker = getFocusableTreeWalker(root, { accept, tabbable });\n\n if (nodeContains(root, node)) {\n walker.currentNode = requireValue(node, \"Expected node\");\n }\n\n let nextNode = focusableElementOrNull(walker.nextNode());\n\n if (!isTruthy(nextNode) && isTruthy(wrap)) {\n walker.currentNode = root;\n nextNode = focusableElementOrNull(walker.nextNode());\n }\n\n if (isTruthy(nextNode)) {\n focusElement(nextNode, true);\n }\n\n return nextNode;\n },\n focusPrevious(opts: FocusManagerOptions = defaultOptions) {\n const root = ref();\n\n if (!root) {\n return null;\n }\n\n const {\n from,\n tabbable = defaultOptions.tabbable,\n wrap = defaultOptions.wrap,\n accept = defaultOptions.accept,\n } = opts;\n\n const node =\n getTruthyValue(from) ?? getActiveElement(getOwnerDocument(root));\n\n const walker = getFocusableTreeWalker(root, { accept, tabbable });\n\n if (nodeContains(root, node)) {\n walker.currentNode = requireValue(node, \"Expected node\");\n } else {\n const next = last(walker);\n\n if (next) {\n focusElement(next, true);\n }\n\n return next ?? null;\n }\n\n let previousNode = focusableElementOrNull(walker.previousNode());\n\n if (!isTruthy(previousNode) && isTruthy(wrap)) {\n walker.currentNode = root;\n const lastNode = last(walker);\n\n if (!lastNode) {\n // couldn't wrap\n return null;\n }\n\n previousNode = lastNode;\n }\n\n if (isTruthy(previousNode)) {\n focusElement(previousNode, true);\n }\n\n return previousNode ?? null;\n },\n };\n}\n\nfunction last(walker: ShadowTreeWalker | TreeWalker) {\n let next;\n let lastValue: FocusableElement | null;\n\n do {\n lastValue = focusableElementOrNull(walker.lastChild());\n\n if (isTruthy(lastValue)) {\n next = lastValue;\n }\n } while (isTruthy(lastValue));\n\n return next;\n}\n\nfunction isRestoreFocusTab(\n e: KeyboardEvent,\n scopeRef: Accessor<Element[] | null>\n): boolean {\n return (\n e.key === \"Tab\" &&\n !e.altKey &&\n !e.ctrlKey &&\n !e.metaKey &&\n shouldContainFocus(scopeRef) &&\n !e.isComposing\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuQgC,O,SAAC,CAAM;;;;;;;;;;;AAlNvC,IAAM,OAAN,MAAM,KAAK;CACT;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AiB,iBAAiB,IAAI,CAAC;GAEjE,MAAM,SAAS,uBAAuB,MAAM;IAAE;IAAQ;GAAS,CAAC;GAEhE,IAAI,aAAa,MAAM,IAAI,GACzB,OAAO,cAAc,aAAa,MAAM,eAAe;QAClD;IACL,MAAM,OAAO,KAAK,MAAM;IAExB,IAAI,MACF,aAAa,MAAM,IAAI;IAGzB,OAAO,QAAQ;GACjB;GAEA,IAAI,eAAe,uBAAuB,OAAO,aAAa,CAAC;GAE/D,IAAI,CAAC,SAAS,YAAY,KAAK,SAAS,IAAI,GAAG;IAC7C,OAAO,cAAc;IACrB,MAAM,WAAW,KAAK,MAAM;IAE5B,IAAI,CAAC,UAEH,OAAO;IAGT,eAAe;GACjB;GAEA,IAAI,SAAS,YAAY,GACvB,aAAa,cAAc,IAAI;GAGjC,OAAO,gBAAgB;EACzB;CACF;AACF;AAEA,SAAS,KAAK,QAAuC;CACnD,IAAI;CACJ,IAAI;CAEJ,GAAG;EACD,YAAY,uBAAuB,OAAO,UAAU,CAAC;EAErD,IAAI,SAAS,SAAS,GACpB,OAAO;CAEX,SAAS,SAAS,SAAS;CAE3B,OAAO;AACT;AAEA,SAAS,kBACP,GACA,UACS;CACT,OACE,EAAE,QAAQ,SACV,CAAC,EAAE,UACH,CAAC,EAAE,WACH,CAAC,EAAE,WACH,mBAAmB,QAAQ,KAC3B,CAAC,EAAE;AAEP"}
1
+ {"version":3,"file":"focus-scope.js","names":["<span\n data-focus-scope-start\n hidden\n ref={(element) => {\n setStartRef(element);\n }}\n />","{content()}","<span\n data-focus-scope-end\n hidden\n ref={(element) => {\n setEndRef(element);\n }}\n />","resolveChildren","_$ssrHydrationKey","_$ssr","_$memo"],"sources":["../../../src/focus/focus-scope.tsx"],"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/focus/FocusScope.tsx.\n * Modified for Solid Aria: adapted hooks, reactive getters, DOM types, and imports for Solid 2; resolve scoped children once under their focus context for rendering and focus tracking.\n * Licensed under Apache-2.0. See LICENSES/Apache-2.0.txt and NOTICE.txt at the repository root.\n */\n\nimport type { FocusableElement } from \"@solid2-aria/types-shared\";\nimport {\n createMemo,\n untrack,\n children as resolveChildren,\n createContext,\n onSettled,\n useContext,\n createEffect,\n createSignal,\n} from \"solid-js\";\nimport type { Accessor, Element as SolidElement } from \"solid-js\";\n\nimport { getInteractionModality } from \"../interactions/create-focus-visible\";\nimport { focusSafely } from \"../interactions/focus-safely\";\nimport type { JSX } from \"../types\";\nimport { getOwnerDocument, getOwnerWindow } from \"../utils/dom-helpers\";\nimport {\n focusableElementOrNull,\n requireElement,\n requireFocusableElement,\n requireHTMLInputElement,\n} from \"../utils/dom-value\";\nimport { isFocusable, isTabbable } from \"../utils/is-focusable\";\nimport { isPresent } from \"../utils/is-present\";\nimport { isAndroid, isChrome } from \"../utils/platform\";\nimport { requireValue } from \"../utils/require-value\";\nimport {\n getActiveElement,\n getEventTarget,\n nodeContains,\n getParentElement,\n} from \"../utils/shadowdom/dom-functions\";\nimport type { ShadowTreeWalker } from \"../utils/shadowdom/shadow-tree-walker\";\nimport { createShadowTreeWalker } from \"../utils/shadowdom/shadow-tree-walker\";\nimport { getTruthyValue, isTruthy, whenTruthy } from \"../utils/truthy\";\n\nclass Tree {\n root: TreeNode;\n private readonly fastMap = new Map<ScopeRef, TreeNode>();\n constructor() {\n this.root = new TreeNode({ scopeRef: null });\n this.fastMap.set(null, this.root);\n }\n get size(): number {\n return this.fastMap.size;\n }\n getTreeNode(data: ScopeRef): TreeNode | undefined {\n return this.fastMap.get(data);\n }\n addTreeNode(\n scopeRef: ScopeRef,\n parent: ScopeRef,\n nodeToRestore?: FocusableElement\n ): void {\n const parentNode = this.fastMap.get(parent ?? null);\n\n if (!parentNode) {\n return;\n }\n\n const node = new TreeNode({ scopeRef });\n parentNode.addChild(node);\n node.parent = parentNode;\n this.fastMap.set(scopeRef, node);\n\n if (nodeToRestore) {\n node.nodeToRestore = nodeToRestore;\n }\n }\n addNode(node: TreeNode): void {\n this.fastMap.set(node.scopeRef, node);\n }\n removeTreeNode(scopeRef: ScopeRef): void {\n // never remove the root\n if (scopeRef === null) {\n return;\n }\n\n const node = this.fastMap.get(scopeRef);\n\n if (!node) {\n return;\n }\n\n const parentNode = node.parent;\n\n // when we remove a scope, check if any sibling scopes are trying to restore focus to something inside the scope we're removing\n // if we are, then replace the siblings restore with the restore from the scope we're removing\n for (const current of this.traverse()) {\n if (\n current !== node &&\n node.nodeToRestore &&\n current.nodeToRestore &&\n node.scopeRef &&\n node.scopeRef() &&\n isElementInScope(current.nodeToRestore, node.scopeRef())\n ) {\n current.nodeToRestore = node.nodeToRestore;\n }\n }\n\n const { children } = node;\n\n if (parentNode) {\n // oxlint-disable-next-line unicorn/prefer-dom-node-remove -- Collection and focus-tree nodes implement their own parent/child protocol.\n parentNode.removeChild(node);\n\n if (children.size > 0) {\n for (const child of children) {\n whenTruthy(parentNode, (truthyValue0) => {\n truthyValue0.addChild(child);\n });\n }\n }\n }\n\n this.fastMap.delete(node.scopeRef);\n }\n // Pre Order Depth First\n *traverse(node: TreeNode = this.root): Generator<TreeNode> {\n if (isPresent(node.scopeRef)) {\n yield node;\n }\n\n if (node.children.size > 0) {\n for (const child of node.children) {\n yield* this.traverse(child);\n }\n }\n }\n clone(): Tree {\n const newTree = new Tree();\n\n for (const node of this.traverse()) {\n newTree.addTreeNode(\n node.scopeRef,\n node.parent?.scopeRef ?? null,\n node.nodeToRestore\n );\n }\n\n return newTree;\n }\n}\n\nclass TreeNode {\n public scopeRef: ScopeRef;\n public nodeToRestore?: FocusableElement;\n public parent?: TreeNode;\n public children = new Set<TreeNode>();\n public contain = false;\n constructor(props: { scopeRef: ScopeRef }) {\n this.scopeRef = untrack(() => props.scopeRef);\n }\n addChild(node: TreeNode): void {\n this.children.add(node);\n node.parent = this;\n }\n removeChild(node: TreeNode): void {\n this.children.delete(node);\n node.parent = undefined;\n }\n}\n\nexport const focusScopeTree: Tree = new Tree();\n\nexport interface FocusScopeProps {\n /** The contents of the focus scope. */\n children: SolidElement;\n /**\n * Whether to contain focus inside the scope, so users cannot\n * move focus outside, for example in a modal dialog.\n */\n contain?: boolean;\n /**\n * Whether to restore focus back to the element that was focused\n * when the focus scope mounted, after the focus scope unmounts.\n */\n restoreFocus?: boolean;\n /** Whether to auto focus the first focusable element in the focus scope on mount. */\n autoFocus?: boolean;\n}\n\nexport interface FocusManagerOptions {\n /** The element to start searching from. The currently focused element by default. */\n from?: Element;\n /** Whether to only include tabbable elements, or all focusable elements. */\n tabbable?: boolean;\n /** Whether focus should wrap around when it reaches the end of the scope. */\n wrap?: boolean;\n /** A callback that determines whether the given element is focused. */\n accept?: (node: Element) => boolean;\n}\n\nexport interface FocusManager {\n /** Moves focus to the next focusable or tabbable element in the focus scope. */\n focusNext: (opts?: FocusManagerOptions) => FocusableElement | null;\n /** Moves focus to the previous focusable or tabbable element in the focus scope. */\n focusPrevious: (opts?: FocusManagerOptions) => FocusableElement | null;\n /** Moves focus to the first focusable or tabbable element in the focus scope. */\n focusFirst: (opts?: FocusManagerOptions) => FocusableElement | null;\n /** Moves focus to the last focusable or tabbable element in the focus scope. */\n focusLast: (opts?: FocusManagerOptions) => FocusableElement | null;\n}\n\ntype ScopeRef = Accessor<Element[] | null> | null;\n\ninterface IFocusContext {\n focusManager: FocusManager;\n parentNode: TreeNode | null;\n}\n\nconst FocusContext = createContext<IFocusContext | null>(null);\nconst RESTORE_FOCUS_EVENT = \"react-aria-focus-scope-restore\";\nlet activeScope: ScopeRef = null;\n\n/**\n * A FocusScope manages focus for its descendants. It supports containing focus inside\n * the scope, restoring focus to the previously focused element on unmount, and auto\n * focusing children on mount. It also acts as a container for a programmatic focus\n * management interface that can be used to move focus forward and back in response\n * to user events.\n */\nconst stopPropagation = (event: Event) => {\n event.stopPropagation();\n};\n\nexport function FocusScope(props: FocusScopeProps): JSX.Element {\n const [startRef, setStartRef] = createSignal<HTMLSpanElement | null>(null, {\n ownedWrite: true,\n });\n\n const [endRef, setEndRef] = createSignal<HTMLSpanElement | null>(null, {\n ownedWrite: true,\n });\n\n const [scopeRef, setScopeRef] = createSignal<Element[]>([], {\n ownedWrite: true,\n });\n\n const parentNode = useContext(FocusContext)?.parentNode;\n const node = new TreeNode({ scopeRef });\n const focusManager = createFocusManagerForScope(scopeRef);\n const value = { focusManager, parentNode: node };\n\n const content = resolveChildren(() => (\n <FocusContext value={value}>{props.children}</FocusContext>\n ));\n\n onSettled(() => {\n let parent = getTruthyValue(parentNode) ?? focusScopeTree.root;\n\n if (\n focusScopeTree.getTreeNode(parent.scopeRef) &&\n activeScope &&\n !isAncestorScope(activeScope, parent.scopeRef)\n ) {\n parent = focusScopeTree.getTreeNode(activeScope) ?? parent;\n }\n\n parent.addChild(node);\n focusScopeTree.addNode(node);\n\n return () => {\n const parentScope =\n focusScopeTree.getTreeNode(scopeRef)?.parent?.scopeRef ?? null;\n\n if (\n (scopeRef === activeScope || isAncestorScope(scopeRef, activeScope)) &&\n (!parentScope || focusScopeTree.getTreeNode(parentScope))\n ) {\n activeScope = parentScope;\n }\n\n focusScopeTree.removeTreeNode(scopeRef);\n };\n });\n createEffect(\n () => props.contain,\n (contain) => {\n node.contain = isTruthy(contain);\n },\n { ssrSource: \"client\" }\n );\n\n createEffect(\n () => ({ content: content(), end: endRef(), start: startRef() }),\n ({ start, end }): undefined | (() => void) => {\n if (!start || !end) {\n return undefined;\n }\n\n let element = start.nextSibling;\n const nodes: Element[] = [];\n\n while (element && element !== end) {\n if (element instanceof Element) {\n nodes.push(element);\n element.addEventListener(RESTORE_FOCUS_EVENT, stopPropagation);\n }\n\n element = element.nextSibling;\n }\n\n setScopeRef(nodes);\n\n return () => {\n for (const elementValue of nodes) {\n elementValue.removeEventListener(\n RESTORE_FOCUS_EVENT,\n stopPropagation\n );\n }\n };\n },\n { ssrSource: \"client\" }\n );\n createActiveScopeTracker(\n scopeRef,\n () => props.restoreFocus,\n () => props.contain\n );\n createFocusContainment(scopeRef, () => props.contain);\n createRestoreFocus(\n scopeRef,\n () => props.restoreFocus,\n () => props.contain\n );\n createAutoFocus(scopeRef, () => props.autoFocus);\n createEffect(\n scopeRef,\n (scopeNodes) => {\n const activeElement = getActiveElement(getOwnerDocument(scopeNodes[0]));\n\n if (isElementInScope(activeElement, scopeNodes)) {\n let scope: TreeNode | null = null;\n\n for (const child of focusScopeTree.traverse()) {\n if (\n child.scopeRef &&\n isElementInScope(activeElement, untrack(child.scopeRef))\n ) {\n scope = child;\n }\n }\n\n if (scope && scope === focusScopeTree.getTreeNode(scopeRef)) {\n activeScope = scope.scopeRef;\n }\n }\n },\n { ssrSource: \"client\" }\n );\n\n return (\n <>\n <span\n data-focus-scope-start\n hidden\n ref={(element) => {\n setStartRef(element);\n }}\n />\n {content()}\n <span\n data-focus-scope-end\n hidden\n ref={(element) => {\n setEndRef(element);\n }}\n />\n </>\n );\n}\n\n/**\n * Returns a FocusManager interface for the parent FocusScope.\n * A FocusManager can be used to programmatically move focus within\n * a FocusScope, e.g. in response to user events like keyboard navigation.\n */\nexport function createFocusScopeManager(): FocusManager | undefined {\n return useContext(FocusContext)?.focusManager;\n}\n\nfunction createFocusManagerForScope(\n scopeRef: Accessor<Element[] | null>\n): FocusManager {\n return {\n focusFirst(opts = {}) {\n const scope = requireValue(scopeRef(), \"Expected focus scope nodes\");\n const { tabbable, accept } = opts;\n const scopeRoot = getScopeRoot(scope);\n\n const walker = getFocusableTreeWalker(\n scopeRoot,\n { accept, tabbable },\n scope\n );\n\n walker.currentNode = requireValue(\n requireValue(scope[0], \"Expected a present traversal value\")\n .previousElementSibling,\n \"Expected scope[0]!.previousElementSibling\"\n );\n const nextNode = focusableElementOrNull(walker.nextNode());\n\n if (isTruthy(nextNode)) {\n focusElement(nextNode, true);\n }\n\n return nextNode;\n },\n focusLast(opts = {}) {\n const scope = requireValue(scopeRef(), \"Expected focus scope nodes\");\n const { tabbable, accept } = opts;\n const scopeRoot = getScopeRoot(scope);\n\n const walker = getFocusableTreeWalker(\n scopeRoot,\n { accept, tabbable },\n scope\n );\n\n walker.currentNode = requireValue(\n requireValue(scope.at(-1), \"Expected a present traversal value\")\n .nextElementSibling,\n \"Expected scope.at(-1)!.nextElementSibling\"\n );\n const previousNode = focusableElementOrNull(walker.previousNode());\n\n if (isTruthy(previousNode)) {\n focusElement(previousNode, true);\n }\n\n return previousNode;\n },\n focusNext(opts: FocusManagerOptions = {}) {\n const scope = requireValue(scopeRef(), \"Expected focus scope nodes\");\n const { from, tabbable, wrap, accept } = opts;\n\n const node =\n getTruthyValue(from) ??\n requireValue(\n getActiveElement(getOwnerDocument(scope[0] ?? undefined)),\n \"Expected getActiveElement(getOwnerDocument(scope[0]! ?? undefined))\"\n );\n\n const sentinel = requireValue(\n requireValue(scope[0], \"Expected a present traversal value\")\n .previousElementSibling,\n \"Expected scope[0]!.previousElementSibling\"\n );\n\n const scopeRoot = getScopeRoot(scope);\n\n const walker = getFocusableTreeWalker(\n scopeRoot,\n { accept, tabbable },\n scope\n );\n\n walker.currentNode = isElementInScope(node, scope) ? node : sentinel;\n let nextNode = focusableElementOrNull(walker.nextNode());\n\n if (!isTruthy(nextNode) && isTruthy(wrap)) {\n walker.currentNode = sentinel;\n nextNode = focusableElementOrNull(walker.nextNode());\n }\n\n if (isTruthy(nextNode)) {\n focusElement(nextNode, true);\n }\n\n return nextNode;\n },\n focusPrevious(opts: FocusManagerOptions = {}) {\n const scope = requireValue(scopeRef(), \"Expected focus scope nodes\");\n const { from, tabbable, wrap, accept } = opts;\n\n const node =\n getTruthyValue(from) ??\n requireValue(\n getActiveElement(getOwnerDocument(scope[0] ?? undefined)),\n \"Expected getActiveElement(getOwnerDocument(scope[0]! ?? undefined))\"\n );\n\n const sentinel = requireValue(\n requireValue(scope.at(-1), \"Expected a present traversal value\")\n .nextElementSibling,\n \"Expected scope[scope.length - 1]!.nextElementSibling\"\n );\n\n const scopeRoot = getScopeRoot(scope);\n\n const walker = getFocusableTreeWalker(\n scopeRoot,\n { accept, tabbable },\n scope\n );\n\n walker.currentNode = isElementInScope(node, scope) ? node : sentinel;\n let previousNode = focusableElementOrNull(walker.previousNode());\n\n if (!isTruthy(previousNode) && isTruthy(wrap)) {\n walker.currentNode = sentinel;\n previousNode = focusableElementOrNull(walker.previousNode());\n }\n\n if (isTruthy(previousNode)) {\n focusElement(previousNode, true);\n }\n\n return previousNode;\n },\n };\n}\n\nfunction getScopeRoot(scope: Element[]) {\n return requireValue(\n getParentElement(scope[0]),\n \"Expected scope[0]!.parentElement\"\n );\n}\n\nfunction shouldContainFocus(scopeRef: ScopeRef) {\n let scope = focusScopeTree.getTreeNode(activeScope);\n\n while (scope && scope.scopeRef !== scopeRef) {\n if (scope.contain) {\n return false;\n }\n\n scope = scope.parent;\n }\n\n return true;\n}\n\nfunction getRadiosInGroup(element: HTMLInputElement): HTMLInputElement[] {\n if (!element.form) {\n // Radio buttons outside a form - query the document\n return [\n ...getOwnerDocument(element).querySelectorAll<HTMLInputElement>(\n `input[type=\"radio\"][name=\"${CSS.escape(element.name)}\"]`\n ),\n ].filter((radio) => !radio.form);\n }\n\n // namedItem returns RadioNodeList (iterable) for 2+ elements, but a single Element for exactly 1.\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormControlsCollection/namedItem\n const radioList = element.form.elements.namedItem(element.name);\n const ownerWindow = getOwnerWindow(element);\n\n if (radioList instanceof ownerWindow.RadioNodeList) {\n return [...radioList].filter(\n (el): el is HTMLInputElement => el instanceof ownerWindow.HTMLInputElement\n );\n }\n\n if (radioList instanceof ownerWindow.HTMLInputElement) {\n return [radioList];\n }\n\n return [];\n}\n\nfunction isTabbableRadio(element: HTMLInputElement): boolean {\n if (element.checked) {\n return true;\n }\n\n const radios = getRadiosInGroup(element);\n\n return radios.length > 0 && !radios.some((radio) => radio.checked);\n}\n\nfunction createFocusContainment(\n scopeRef: Accessor<Element[] | null>,\n contain: () => boolean | undefined\n) {\n let focusedNode: FocusableElement | undefined;\n\n let raf: ReturnType<typeof requestAnimationFrame> | undefined;\n\n createEffect(\n () => ({ contain: contain(), scope: scopeRef() }),\n ({ scope, contain: shouldContain }): undefined | (() => void) => {\n if (scope === null || scope.length === 0) {\n return undefined;\n }\n\n if (!isTruthy(shouldContain)) {\n // if contain() was changed, then we should cancel any ongoing waits to pull focus back into containment\n if (raf !== undefined) {\n cancelAnimationFrame(raf);\n raf = undefined;\n }\n\n return undefined;\n }\n\n const ownerDocument = getOwnerDocument(\n requireValue(scope[0], \"Expected first scope element\")\n );\n\n // Handle the Tab key to contain() focus within the scope\n const onKeyDown = (e: KeyboardEvent) => {\n if (!isRestoreFocusTab(e, scopeRef)) {\n return;\n }\n\n const focusedElement = getActiveElement(ownerDocument);\n const scopeValue = scopeRef();\n\n if (!scopeValue || !isElementInScope(focusedElement, scopeValue)) {\n return;\n }\n\n const scopeRoot = getScopeRoot(scopeValue);\n\n const walker = getFocusableTreeWalker(\n scopeRoot,\n { tabbable: true },\n scopeValue\n );\n\n if (!focusedElement) {\n return;\n }\n\n walker.currentNode = focusedElement;\n\n let nextElement = focusableElementOrNull(\n e.shiftKey ? walker.previousNode() : walker.nextNode()\n );\n\n if (!isTruthy(nextElement)) {\n walker.currentNode = e.shiftKey\n ? requireValue(\n requireValue(\n scopeValue.at(-1),\n \"Expected a present traversal value\"\n ).nextElementSibling,\n \"Expected scope.at(-1)!.nextElementSibling\"\n )\n : requireValue(\n requireValue(\n scopeValue[0],\n \"Expected a present traversal value\"\n ).previousElementSibling,\n \"Expected scope[0]!.previousElementSibling\"\n );\n nextElement = focusableElementOrNull(\n e.shiftKey ? walker.previousNode() : walker.nextNode()\n );\n }\n\n e.preventDefault();\n\n if (isTruthy(nextElement)) {\n focusElement(nextElement, true);\n\n if (\n nextElement instanceof getOwnerWindow(nextElement).HTMLInputElement\n ) {\n nextElement.select();\n }\n }\n };\n\n const onFocus: EventListener = (e) => {\n // If focusing an element in a child scope of the currently active scope, the child becomes active.\n // Moving out of the active scope to an ancestor is not allowed.\n if (\n (!activeScope || isAncestorScope(activeScope, scopeRef)) &&\n isElementInScope(requireElement(getEventTarget(e)), scope)\n ) {\n activeScope = scopeRef;\n focusedNode = requireFocusableElement(getEventTarget(e));\n } else if (\n shouldContainFocus(scopeRef) &&\n !isElementInChildScope(requireElement(getEventTarget(e)), scopeRef)\n ) {\n // If a focus event occurs outside the active scope (e.g. user tabs from browser location bar),\n // restore focus to the previously focused node or the first tabbable element in the active scope.\n if (focusedNode) {\n focusElement(focusedNode);\n } else {\n const activeNodes = activeScope?.();\n\n if (activeNodes) {\n focusFirstInScope(activeNodes);\n }\n }\n } else if (shouldContainFocus(scopeRef)) {\n focusedNode = requireFocusableElement(getEventTarget(e));\n }\n };\n\n const onBlur: EventListener = (e) => {\n // Firefox doesn't shift focus back to the Dialog properly without this\n if (raf !== undefined) {\n cancelAnimationFrame(raf);\n }\n\n raf = requestAnimationFrame(() => {\n // Patches infinite focus coersion loop for Android Talkback where the user isn't able to move the virtual cursor\n // if within a containing focus scope. Bug filed against Chrome: https://issuetracker.google.com/issues/384844019.\n // Note that this means focus can leave focus containing modals due to this, but it is isolated to Chrome Talkback.\n const modality = getInteractionModality();\n\n const shouldSkipFocusRestore =\n (modality === \"virtual\" || modality === null) &&\n isAndroid() &&\n isChrome();\n\n // Use document.activeElement instead of e.relatedTarget so we can tell if user clicked into iframe\n const activeElement = getActiveElement(ownerDocument);\n\n if (\n !shouldSkipFocusRestore &&\n activeElement &&\n shouldContainFocus(scopeRef) &&\n !isElementInChildScope(activeElement, scopeRef)\n ) {\n activeScope = scopeRef;\n const target = requireFocusableElement(getEventTarget(e));\n\n if (isTruthy(target) && target.isConnected) {\n focusedNode = target;\n focusElement(focusedNode);\n } else {\n const activeNodes = activeScope();\n\n if (activeNodes) {\n focusFirstInScope(activeNodes);\n }\n }\n }\n });\n };\n\n ownerDocument.addEventListener(\"keydown\", onKeyDown, false);\n ownerDocument.addEventListener(\"focusin\", onFocus, false);\n\n for (const element of scope ?? []) {\n element.addEventListener(\"focusin\", onFocus, false);\n }\n\n for (const element of scope ?? []) {\n element.addEventListener(\"focusout\", onBlur, false);\n }\n\n return () => {\n ownerDocument.removeEventListener(\"keydown\", onKeyDown, false);\n ownerDocument.removeEventListener(\"focusin\", onFocus, false);\n\n for (const element of scope ?? []) {\n element.removeEventListener(\"focusin\", onFocus, false);\n }\n\n for (const element of scope ?? []) {\n element.removeEventListener(\"focusout\", onBlur, false);\n }\n };\n },\n { ssrSource: \"client\" }\n );\n onSettled(() => () => {\n if (raf !== undefined) {\n cancelAnimationFrame(raf);\n }\n });\n}\n\nfunction isElementInAnyScope(element: Element) {\n return isElementInChildScope(element);\n}\n\nfunction isElementInScope(element?: Element | null, scope?: Element[] | null) {\n if (!element) {\n return false;\n }\n\n if (!scope) {\n return false;\n }\n\n return scope.some((node) => nodeContains(node, element));\n}\n\nfunction isElementInChildScope(element: Element, scope: ScopeRef = null) {\n // If the element is within a top layer element (e.g. toasts), always allow moving focus there.\n if (\n element instanceof Element &&\n element.closest(\"[data-react-aria-top-layer]\")\n ) {\n return true;\n }\n\n // node.contains in isElementInScope covers child scopes that are also DOM children,\n // but does not cover child scopes in portals.\n for (const { scopeRef: s } of focusScopeTree.traverse(\n focusScopeTree.getTreeNode(scope)\n )) {\n if (s && isElementInScope(element, untrack(s))) {\n return true;\n }\n }\n\n return false;\n}\n\n/** @private */\nexport function isElementInChildOfActiveScope(element: Element): boolean {\n return isElementInChildScope(element, activeScope);\n}\n\nfunction isAncestorScope(ancestor: ScopeRef, scope: ScopeRef) {\n let parent = focusScopeTree.getTreeNode(scope)?.parent;\n\n while (parent) {\n if (parent.scopeRef === ancestor) {\n return true;\n }\n\n ({ parent } = parent);\n }\n\n return false;\n}\n\nfunction focusElement(element: FocusableElement | null, scroll = false) {\n if (isPresent(element) && !scroll) {\n try {\n focusSafely(element);\n } catch {\n // ignore\n }\n } else if (isPresent(element)) {\n try {\n element.focus();\n } catch {\n // ignore\n }\n }\n}\n\nfunction getFirstInScope(\n scope: Element[],\n tabbable = true\n): FocusableElement | null {\n const sentinel = requireValue(\n requireValue(scope[0], \"Expected a present traversal value\")\n .previousElementSibling,\n \"Expected scope[0]!.previousElementSibling\"\n );\n\n let scopeRoot = getScopeRoot(scope);\n let walker = getFocusableTreeWalker(scopeRoot, { tabbable }, scope);\n walker.currentNode = sentinel;\n let nextNode = walker.nextNode();\n\n // If the scope does not contain a tabbable element, use the first focusable element.\n if (tabbable && !nextNode) {\n scopeRoot = getScopeRoot(scope);\n walker = getFocusableTreeWalker(scopeRoot, { tabbable: false }, scope);\n walker.currentNode = sentinel;\n nextNode = walker.nextNode();\n }\n\n // TreeWalker.nextNode() returns null when the scope contains no focusable element.\n return focusableElementOrNull(nextNode);\n}\n\nfunction focusFirstInScope(scope: Element[], tabbable = true) {\n focusElement(getFirstInScope(scope, tabbable));\n}\n\nfunction createAutoFocus(\n scopeRef: Accessor<Element[] | null>,\n autoFocus: () => boolean | undefined\n) {\n let pendingAutoFocus = untrack(autoFocus);\n createEffect(\n scopeRef,\n (scope) => {\n if (!isTruthy(pendingAutoFocus) || scope === null || scope.length === 0) {\n return;\n }\n\n pendingAutoFocus = false;\n activeScope = scopeRef;\n const ownerDocument = getOwnerDocument(scope[0]);\n\n if (!isElementInScope(getActiveElement(ownerDocument), scope)) {\n focusFirstInScope(scope);\n }\n },\n { ssrSource: \"client\" }\n );\n}\n\nfunction createActiveScopeTracker(\n scopeRef: Accessor<Element[] | null>,\n restore: () => boolean | undefined,\n contain: () => boolean | undefined\n) {\n // Track active scopes that do not contain or restore focus.\n createEffect(\n () => ({ contain: contain(), restore: restore(), scope: scopeRef() }),\n ({\n scope,\n restore: shouldRestore,\n contain: shouldContain,\n }): undefined | (() => void) => {\n if (\n scope === null ||\n scope.length === 0 ||\n isTruthy(shouldRestore) ||\n isTruthy(shouldContain)\n ) {\n return undefined;\n }\n\n const ownerDocument = getOwnerDocument(\n requireValue(scope[0], \"Expected first scope element\")\n );\n\n const onFocus = (e: Event) => {\n const target = requireElement(getEventTarget(e));\n\n if (isElementInScope(target, scope)) {\n activeScope = scopeRef;\n } else if (!isElementInAnyScope(target)) {\n activeScope = null;\n }\n };\n\n ownerDocument.addEventListener(\"focusin\", onFocus, false);\n\n for (const element of scope ?? []) {\n element.addEventListener(\"focusin\", onFocus, false);\n }\n\n return () => {\n ownerDocument.removeEventListener(\"focusin\", onFocus, false);\n\n for (const element of scope ?? []) {\n element.removeEventListener(\"focusin\", onFocus, false);\n }\n };\n },\n { ssrSource: \"client\" }\n );\n}\n\nfunction shouldRestoreFocus(scopeRef: ScopeRef) {\n let scope = focusScopeTree.getTreeNode(activeScope);\n\n while (scope && scope.scopeRef !== scopeRef) {\n if (scope.nodeToRestore) {\n return false;\n }\n\n scope = scope.parent;\n }\n\n return scope?.scopeRef === scopeRef;\n}\n\nfunction createRestoreFocus(\n scopeRef: Accessor<Element[] | null>,\n restoreFocus: () => boolean | undefined,\n contain: () => boolean | undefined\n) {\n // Capture focus before scoped children can autofocus.\n const initialFocusTarget = untrack(() =>\n typeof document === \"undefined\"\n ? null\n : focusableElementOrNull(\n getActiveElement(getOwnerDocument(scopeRef()?.[0]))\n )\n );\n\n const scopeReady = createMemo(() => (scopeRef()?.length ?? 0) > 0);\n\n // restoring scopes should all track if they are active regardless of contain(), but contain() already tracks it plus logic to contain() the focus\n // restoring-non-containing scopes should only care if they become active so they can perform the restore\n createEffect(\n () => ({ contain: contain(), restore: restoreFocus(), scope: scopeRef() }),\n ({\n scope,\n restore: shouldRestore,\n contain: shouldContain,\n }): undefined | (() => void) => {\n if (scope === null || scope.length === 0) {\n return undefined;\n }\n\n const ownerDocument = getOwnerDocument(\n requireValue(scope[0], \"Expected first scope element\")\n );\n\n if (!isTruthy(shouldRestore) || isTruthy(shouldContain)) {\n return undefined;\n }\n\n const onFocus = () => {\n // If focusing an element in a child scope of the currently active scope, the child becomes active.\n // Moving out of the active scope to an ancestor is not allowed.\n if (\n (!activeScope || isAncestorScope(activeScope, scopeRef)) &&\n isElementInScope(getActiveElement(ownerDocument), scope)\n ) {\n activeScope = scopeRef;\n }\n };\n\n ownerDocument.addEventListener(\"focusin\", onFocus, false);\n\n for (const element of scope ?? []) {\n element.addEventListener(\"focusin\", onFocus, false);\n }\n\n return () => {\n ownerDocument.removeEventListener(\"focusin\", onFocus, false);\n\n for (const element of scope ?? []) {\n element.removeEventListener(\"focusin\", onFocus, false);\n }\n };\n },\n { ssrSource: \"client\" }\n );\n createEffect(\n () => ({ contain: contain(), restore: restoreFocus(), scope: scopeRef() }),\n ({\n scope,\n restore: shouldRestore,\n contain: shouldContain,\n }): undefined | (() => void) => {\n if (scope === null || scope.length === 0) {\n return undefined;\n }\n\n const ownerDocument = getOwnerDocument(scope[0]);\n\n if (!isTruthy(shouldRestore)) {\n return undefined;\n }\n\n // Handle the Tab key so that tabbing out of the scope goes to the next element\n // after the node that had focus when the scope mounted. This is important when\n // using portals for overlays, so that focus goes to the expected element when\n // tabbing out of the overlay.\n const onKeyDown = (e: KeyboardEvent) => {\n if (!isRestoreFocusTab(e, scopeRef)) {\n return;\n }\n\n const focusedElement = focusableElementOrNull(\n ownerDocument.activeElement\n );\n\n if (\n focusedElement === null ||\n !isElementInChildScope(focusedElement, scopeRef) ||\n !shouldRestoreFocus(scopeRef)\n ) {\n return;\n }\n\n const treeNode = focusScopeTree.getTreeNode(scopeRef);\n\n if (!treeNode) {\n return;\n }\n\n let { nodeToRestore } = treeNode;\n\n // Create a DOM tree walker that matches all tabbable elements\n const walker = getFocusableTreeWalker(ownerDocument.body, {\n tabbable: true,\n });\n\n // Find the next tabbable element after the currently focused element\n walker.currentNode = focusedElement;\n\n let nextElement = focusableElementOrNull(\n e.shiftKey ? walker.previousNode() : walker.nextNode()\n );\n\n if (\n !nodeToRestore ||\n !nodeToRestore.isConnected ||\n nodeToRestore === ownerDocument.body\n ) {\n nodeToRestore = undefined;\n treeNode.nodeToRestore = undefined;\n }\n\n // If there is no next element, or it is outside the current scope, move focus to the\n // next element after the node to restore to instead.\n if (\n (!isTruthy(nextElement) ||\n !isElementInChildScope(nextElement, scopeRef)) &&\n nodeToRestore\n ) {\n walker.currentNode = nodeToRestore;\n\n // Skip over elements within the scope, in case the scope immediately follows the node to restore.\n do {\n nextElement = focusableElementOrNull(\n e.shiftKey ? walker.previousNode() : walker.nextNode()\n );\n } while (\n nextElement !== null &&\n isElementInChildScope(nextElement, scopeRef)\n );\n\n e.preventDefault();\n e.stopPropagation();\n\n if (isTruthy(nextElement)) {\n focusElement(nextElement, true);\n } else if (isElementInAnyScope(nodeToRestore)) {\n focusElement(nodeToRestore, true);\n } else {\n focusedElement.blur();\n }\n }\n };\n\n if (!isTruthy(shouldContain)) {\n ownerDocument.addEventListener(\"keydown\", onKeyDown, true);\n }\n\n return () => {\n if (!isTruthy(shouldContain)) {\n ownerDocument.removeEventListener(\"keydown\", onKeyDown, true);\n }\n };\n },\n { ssrSource: \"client\" }\n );\n createEffect(\n () => ({ ready: scopeReady(), restore: restoreFocus() }),\n ({ ready, restore: shouldRestore }): undefined | (() => void) => {\n if (!ready || !isTruthy(shouldRestore)) {\n return undefined;\n }\n\n const ownerDocument = getOwnerDocument(untrack(scopeRef)?.[0]);\n\n if (!isTruthy(shouldRestore)) {\n return undefined;\n }\n\n const treeNode = focusScopeTree.getTreeNode(scopeRef);\n\n if (!treeNode) {\n return undefined;\n }\n\n treeNode.nodeToRestore = initialFocusTarget ?? undefined;\n\n return () => {\n const treeNodeValue = focusScopeTree.getTreeNode(scopeRef);\n\n if (!treeNodeValue) {\n return;\n }\n\n const { nodeToRestore } = treeNodeValue;\n // if we already lost focus to the body and this was the active scope, then we should attempt to restore\n const activeElement = getActiveElement(ownerDocument);\n\n if (\n isTruthy(untrack(restoreFocus)) &&\n nodeToRestore &&\n ((activeElement && isElementInChildScope(activeElement, scopeRef)) ||\n (activeElement === ownerDocument.body &&\n shouldRestoreFocus(scopeRef)))\n ) {\n // freeze the focusScopeTree so it persists after the raf, otherwise during unmount nodes are removed from it\n const clonedTree = focusScopeTree.clone();\n requestAnimationFrame(() => {\n // Only restore focus if we've lost focus to the body, the alternative is that focus has been purposefully moved elsewhere\n if (ownerDocument.activeElement === ownerDocument.body) {\n // look up the tree starting with our scope to find a nodeToRestore still in the DOM\n let treeNodeValue2 = clonedTree.getTreeNode(scopeRef);\n\n while (treeNodeValue2) {\n if (\n treeNodeValue2.nodeToRestore &&\n treeNodeValue2.nodeToRestore.isConnected\n ) {\n restoreFocusToElement(treeNodeValue2.nodeToRestore);\n\n return;\n }\n\n treeNodeValue2 = treeNodeValue2.parent;\n }\n\n // If no nodeToRestore was found, focus the first element in the nearest\n // ancestor scope that is still in the tree.\n treeNodeValue2 = clonedTree.getTreeNode(scopeRef);\n\n while (treeNodeValue2) {\n const scopeNodes = treeNodeValue2.scopeRef?.();\n\n if (\n scopeNodes &&\n focusScopeTree.getTreeNode(treeNodeValue2.scopeRef)\n ) {\n const node = getFirstInScope(scopeNodes, true);\n\n // The scope may have nothing focusable in it, e.g. if its focusable\n // content was removed or hidden. Keep walking up in that case.\n if (node) {\n restoreFocusToElement(node);\n\n return;\n }\n }\n\n treeNodeValue2 = treeNodeValue2.parent;\n }\n }\n });\n }\n };\n },\n { ssrSource: \"client\" }\n );\n}\n\nfunction restoreFocusToElement(node: FocusableElement) {\n // Dispatch a custom event that parent elements can intercept to customize focus restoration.\n // For example, virtualized collection components reuse DOM elements, so the original element\n // might still exist in the DOM but representing a different item.\n if (\n node.dispatchEvent(\n new CustomEvent(RESTORE_FOCUS_EVENT, { bubbles: true, cancelable: true })\n )\n ) {\n focusElement(node);\n }\n}\n\n/**\n * Create a [TreeWalker]{@link https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker}\n * that matches all focusable/tabbable elements.\n */\nexport function getFocusableTreeWalker(\n root: Element,\n opts?: FocusManagerOptions,\n scope?: Element[]\n): ShadowTreeWalker | TreeWalker {\n const filter = isTruthy(opts?.tabbable) ? isTabbable : isFocusable;\n // Ensure that root is an Element or fall back appropriately\n const rootElement = root?.nodeType === Node.ELEMENT_NODE ? root : null;\n // Determine the document to use\n const doc = getOwnerDocument(rootElement);\n\n // Create a TreeWalker, ensuring the root is an Element or Document\n const walker = createShadowTreeWalker(\n doc,\n getTruthyValue(root) ?? doc,\n NodeFilter.SHOW_ELEMENT,\n {\n acceptNode(node) {\n // Skip nodes inside the starting node.\n if (nodeContains(opts?.from, node)) {\n return NodeFilter.FILTER_REJECT;\n }\n\n if (\n isTruthy(opts?.tabbable) &&\n requireElement(node).tagName === \"INPUT\" &&\n requireHTMLInputElement(node).getAttribute(\"type\") === \"radio\"\n ) {\n // If the radio is in a form, we can get all the other radios by name\n if (!isTabbableRadio(requireHTMLInputElement(node))) {\n return NodeFilter.FILTER_REJECT;\n }\n\n // If the radio is in the same group as the current node and none are selected, we can skip it\n if (\n requireElement(walker.currentNode).tagName === \"INPUT\" &&\n requireHTMLInputElement(walker.currentNode).type === \"radio\" &&\n requireHTMLInputElement(walker.currentNode).name ===\n requireHTMLInputElement(node).name\n ) {\n return NodeFilter.FILTER_REJECT;\n }\n }\n\n if (\n filter(requireElement(node)) &&\n (!scope || isElementInScope(requireElement(node), scope)) &&\n (!opts?.accept || opts.accept(requireElement(node)))\n ) {\n return NodeFilter.FILTER_ACCEPT;\n }\n\n return NodeFilter.FILTER_SKIP;\n },\n }\n );\n\n if (opts?.from) {\n walker.currentNode = opts.from;\n }\n\n return walker;\n}\n\n/**\n * Creates a FocusManager object that can be used to move focus within an element.\n */\nexport function createFocusManager(\n ref: Accessor<Element | null>,\n defaultOptions: FocusManagerOptions = {}\n): FocusManager {\n return {\n focusFirst(opts = defaultOptions) {\n const root = ref();\n\n if (!root) {\n return null;\n }\n\n const {\n tabbable = defaultOptions.tabbable,\n accept = defaultOptions.accept,\n } = opts;\n\n const walker = getFocusableTreeWalker(root, { accept, tabbable });\n const nextNode = focusableElementOrNull(walker.nextNode());\n\n if (isTruthy(nextNode)) {\n focusElement(nextNode, true);\n }\n\n return nextNode;\n },\n focusLast(opts = defaultOptions) {\n const root = ref();\n\n if (!root) {\n return null;\n }\n\n const {\n tabbable = defaultOptions.tabbable,\n accept = defaultOptions.accept,\n } = opts;\n\n const walker = getFocusableTreeWalker(root, { accept, tabbable });\n const next = last(walker);\n\n if (next) {\n focusElement(next, true);\n }\n\n return next ?? null;\n },\n focusNext(opts: FocusManagerOptions = {}) {\n const root = ref();\n\n if (!root) {\n return null;\n }\n\n const {\n from,\n tabbable = defaultOptions.tabbable,\n wrap = defaultOptions.wrap,\n accept = defaultOptions.accept,\n } = opts;\n\n const node =\n getTruthyValue(from) ?? getActiveElement(getOwnerDocument(root));\n\n const walker = getFocusableTreeWalker(root, { accept, tabbable });\n\n if (nodeContains(root, node)) {\n walker.currentNode = requireValue(node, \"Expected node\");\n }\n\n let nextNode = focusableElementOrNull(walker.nextNode());\n\n if (!isTruthy(nextNode) && isTruthy(wrap)) {\n walker.currentNode = root;\n nextNode = focusableElementOrNull(walker.nextNode());\n }\n\n if (isTruthy(nextNode)) {\n focusElement(nextNode, true);\n }\n\n return nextNode;\n },\n focusPrevious(opts: FocusManagerOptions = defaultOptions) {\n const root = ref();\n\n if (!root) {\n return null;\n }\n\n const {\n from,\n tabbable = defaultOptions.tabbable,\n wrap = defaultOptions.wrap,\n accept = defaultOptions.accept,\n } = opts;\n\n const node =\n getTruthyValue(from) ?? getActiveElement(getOwnerDocument(root));\n\n const walker = getFocusableTreeWalker(root, { accept, tabbable });\n\n if (nodeContains(root, node)) {\n walker.currentNode = requireValue(node, \"Expected node\");\n } else {\n const next = last(walker);\n\n if (next) {\n focusElement(next, true);\n }\n\n return next ?? null;\n }\n\n let previousNode = focusableElementOrNull(walker.previousNode());\n\n if (!isTruthy(previousNode) && isTruthy(wrap)) {\n walker.currentNode = root;\n const lastNode = last(walker);\n\n if (!lastNode) {\n // couldn't wrap\n return null;\n }\n\n previousNode = lastNode;\n }\n\n if (isTruthy(previousNode)) {\n focusElement(previousNode, true);\n }\n\n return previousNode ?? null;\n },\n };\n}\n\nfunction last(walker: ShadowTreeWalker | TreeWalker) {\n let next;\n let lastValue: FocusableElement | null;\n\n do {\n lastValue = focusableElementOrNull(walker.lastChild());\n\n if (isTruthy(lastValue)) {\n next = lastValue;\n }\n } while (isTruthy(lastValue));\n\n return next;\n}\n\nfunction isRestoreFocusTab(\n e: KeyboardEvent,\n scopeRef: Accessor<Element[] | null>\n): boolean {\n return (\n e.key === \"Tab\" &&\n !e.altKey &&\n !e.ctrlKey &&\n !e.metaKey &&\n shouldContainFocus(scopeRef) &&\n !e.isComposing\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwQgC,O,SAAC,CAAM;;;;;;;;;;;AAlNvC,IAAM,OAAN,MAAM,KAAK;CACT;CACA,0BAA2B,IAAI,IAAwB;CACvD,cAAc;EACZ,KAAK,OAAO,IAAI,SAAS,EAAE,UAAU,KAAK,CAAC;EAC3C,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;CAClC;CACA,IAAI,OAAe;EACjB,OAAO,KAAK,QAAQ;CACtB;CACA,YAAY,MAAsC;EAChD,OAAO,KAAK,QAAQ,IAAI,IAAI;CAC9B;CACA,YACE,UACA,QACA,eACM;EACN,MAAM,aAAa,KAAK,QAAQ,IAAI,UAAU,IAAI;EAElD,IAAI,CAAC,YACH;EAGF,MAAM,OAAO,IAAI,SAAS,EAAE,SAAS,CAAC;EACtC,WAAW,SAAS,IAAI;EACxB,KAAK,SAAS;EACd,KAAK,QAAQ,IAAI,UAAU,IAAI;EAE/B,IAAI,eACF,KAAK,gBAAgB;CAEzB;CACA,QAA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