@octanejs/aria 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -3
- package/src/breadcrumbs/useBreadcrumbItem.ts +95 -0
- package/src/breadcrumbs/useBreadcrumbs.ts +51 -0
- package/src/button/useButton.ts +273 -0
- package/src/button/useToggleButton.ts +131 -0
- package/src/button/useToggleButtonGroup.ts +131 -0
- package/src/checkbox/useCheckbox.ts +114 -0
- package/src/checkbox/useCheckboxGroup.ts +107 -0
- package/src/checkbox/useCheckboxGroupItem.ts +132 -0
- package/src/checkbox/utils.ts +15 -0
- package/src/combobox/useComboBox.ts +602 -0
- package/src/dialog/useDialog.ts +147 -0
- package/src/disclosure/useDisclosure.ts +180 -0
- package/src/focus/FocusRing.ts +69 -0
- package/src/focus/FocusScope.ts +1205 -0
- package/src/focus/useFocusRing.ts +125 -0
- package/src/focus/useHasTabbableChild.ts +82 -0
- package/src/focus/virtualFocus.ts +38 -0
- package/src/form/useFormValidation.ts +205 -0
- package/src/grid/useGridSelectionAnnouncement.ts +177 -0
- package/src/grid/useGridSelectionCheckbox.ts +86 -0
- package/src/grid/useHighlightSelectionDescription.ts +81 -0
- package/src/gridlist/useGridList.ts +236 -0
- package/src/gridlist/useGridListItem.ts +512 -0
- package/src/gridlist/useGridListSection.ts +78 -0
- package/src/gridlist/useGridListSelectionCheckbox.ts +47 -0
- package/src/gridlist/utils.ts +36 -0
- package/src/i18n/I18nProvider.ts +97 -0
- package/src/i18n/server.ts +115 -0
- package/src/i18n/useCollator.ts +42 -0
- package/src/i18n/useDateFormatter.ts +64 -0
- package/src/i18n/useDefaultLocale.ts +93 -0
- package/src/i18n/useFilter.ts +107 -0
- package/src/i18n/useListFormatter.ts +33 -0
- package/src/i18n/useLocalizedStringFormatter.ts +90 -0
- package/src/i18n/useNumberFormatter.ts +33 -0
- package/src/i18n/utils.ts +67 -0
- package/src/index.ts +268 -0
- package/src/intl/breadcrumbs/ar-AE.json +3 -0
- package/src/intl/breadcrumbs/bg-BG.json +3 -0
- package/src/intl/breadcrumbs/cs-CZ.json +3 -0
- package/src/intl/breadcrumbs/da-DK.json +3 -0
- package/src/intl/breadcrumbs/de-DE.json +3 -0
- package/src/intl/breadcrumbs/el-GR.json +3 -0
- package/src/intl/breadcrumbs/en-US.json +3 -0
- package/src/intl/breadcrumbs/es-ES.json +3 -0
- package/src/intl/breadcrumbs/et-EE.json +3 -0
- package/src/intl/breadcrumbs/fi-FI.json +3 -0
- package/src/intl/breadcrumbs/fr-FR.json +3 -0
- package/src/intl/breadcrumbs/he-IL.json +3 -0
- package/src/intl/breadcrumbs/hr-HR.json +3 -0
- package/src/intl/breadcrumbs/hu-HU.json +3 -0
- package/src/intl/breadcrumbs/index.ts +75 -0
- package/src/intl/breadcrumbs/it-IT.json +3 -0
- package/src/intl/breadcrumbs/ja-JP.json +3 -0
- package/src/intl/breadcrumbs/ko-KR.json +3 -0
- package/src/intl/breadcrumbs/lt-LT.json +3 -0
- package/src/intl/breadcrumbs/lv-LV.json +3 -0
- package/src/intl/breadcrumbs/nb-NO.json +3 -0
- package/src/intl/breadcrumbs/nl-NL.json +3 -0
- package/src/intl/breadcrumbs/pl-PL.json +3 -0
- package/src/intl/breadcrumbs/pt-BR.json +3 -0
- package/src/intl/breadcrumbs/pt-PT.json +3 -0
- package/src/intl/breadcrumbs/ro-RO.json +3 -0
- package/src/intl/breadcrumbs/ru-RU.json +3 -0
- package/src/intl/breadcrumbs/sk-SK.json +3 -0
- package/src/intl/breadcrumbs/sl-SI.json +3 -0
- package/src/intl/breadcrumbs/sr-SP.json +3 -0
- package/src/intl/breadcrumbs/sv-SE.json +3 -0
- package/src/intl/breadcrumbs/tr-TR.json +3 -0
- package/src/intl/breadcrumbs/uk-UA.json +3 -0
- package/src/intl/breadcrumbs/zh-CN.json +3 -0
- package/src/intl/breadcrumbs/zh-TW.json +3 -0
- package/src/intl/combobox/ar-AE.json +7 -0
- package/src/intl/combobox/bg-BG.json +7 -0
- package/src/intl/combobox/cs-CZ.json +7 -0
- package/src/intl/combobox/da-DK.json +7 -0
- package/src/intl/combobox/de-DE.json +7 -0
- package/src/intl/combobox/el-GR.json +7 -0
- package/src/intl/combobox/en-US.json +7 -0
- package/src/intl/combobox/es-ES.json +7 -0
- package/src/intl/combobox/et-EE.json +7 -0
- package/src/intl/combobox/fi-FI.json +7 -0
- package/src/intl/combobox/fr-FR.json +7 -0
- package/src/intl/combobox/he-IL.json +7 -0
- package/src/intl/combobox/hr-HR.json +7 -0
- package/src/intl/combobox/hu-HU.json +7 -0
- package/src/intl/combobox/index.ts +75 -0
- package/src/intl/combobox/it-IT.json +7 -0
- package/src/intl/combobox/ja-JP.json +7 -0
- package/src/intl/combobox/ko-KR.json +7 -0
- package/src/intl/combobox/lt-LT.json +7 -0
- package/src/intl/combobox/lv-LV.json +7 -0
- package/src/intl/combobox/nb-NO.json +7 -0
- package/src/intl/combobox/nl-NL.json +7 -0
- package/src/intl/combobox/pl-PL.json +7 -0
- package/src/intl/combobox/pt-BR.json +7 -0
- package/src/intl/combobox/pt-PT.json +7 -0
- package/src/intl/combobox/ro-RO.json +7 -0
- package/src/intl/combobox/ru-RU.json +7 -0
- package/src/intl/combobox/sk-SK.json +7 -0
- package/src/intl/combobox/sl-SI.json +7 -0
- package/src/intl/combobox/sr-SP.json +7 -0
- package/src/intl/combobox/sv-SE.json +7 -0
- package/src/intl/combobox/tr-TR.json +7 -0
- package/src/intl/combobox/uk-UA.json +7 -0
- package/src/intl/combobox/zh-CN.json +7 -0
- package/src/intl/combobox/zh-TW.json +7 -0
- package/src/intl/grid/ar-AE.json +8 -0
- package/src/intl/grid/bg-BG.json +8 -0
- package/src/intl/grid/cs-CZ.json +8 -0
- package/src/intl/grid/da-DK.json +8 -0
- package/src/intl/grid/de-DE.json +8 -0
- package/src/intl/grid/el-GR.json +8 -0
- package/src/intl/grid/en-US.json +8 -0
- package/src/intl/grid/es-ES.json +8 -0
- package/src/intl/grid/et-EE.json +8 -0
- package/src/intl/grid/fi-FI.json +8 -0
- package/src/intl/grid/fr-FR.json +8 -0
- package/src/intl/grid/he-IL.json +8 -0
- package/src/intl/grid/hr-HR.json +8 -0
- package/src/intl/grid/hu-HU.json +8 -0
- package/src/intl/grid/index.ts +75 -0
- package/src/intl/grid/it-IT.json +8 -0
- package/src/intl/grid/ja-JP.json +8 -0
- package/src/intl/grid/ko-KR.json +8 -0
- package/src/intl/grid/lt-LT.json +8 -0
- package/src/intl/grid/lv-LV.json +8 -0
- package/src/intl/grid/nb-NO.json +8 -0
- package/src/intl/grid/nl-NL.json +8 -0
- package/src/intl/grid/pl-PL.json +8 -0
- package/src/intl/grid/pt-BR.json +8 -0
- package/src/intl/grid/pt-PT.json +8 -0
- package/src/intl/grid/ro-RO.json +8 -0
- package/src/intl/grid/ru-RU.json +8 -0
- package/src/intl/grid/sk-SK.json +8 -0
- package/src/intl/grid/sl-SI.json +8 -0
- package/src/intl/grid/sr-SP.json +8 -0
- package/src/intl/grid/sv-SE.json +8 -0
- package/src/intl/grid/tr-TR.json +8 -0
- package/src/intl/grid/uk-UA.json +8 -0
- package/src/intl/grid/zh-CN.json +8 -0
- package/src/intl/grid/zh-TW.json +8 -0
- package/src/intl/gridlist/ar-AE.json +4 -0
- package/src/intl/gridlist/bg-BG.json +4 -0
- package/src/intl/gridlist/cs-CZ.json +4 -0
- package/src/intl/gridlist/da-DK.json +4 -0
- package/src/intl/gridlist/de-DE.json +4 -0
- package/src/intl/gridlist/el-GR.json +4 -0
- package/src/intl/gridlist/en-US.json +4 -0
- package/src/intl/gridlist/es-ES.json +4 -0
- package/src/intl/gridlist/et-EE.json +4 -0
- package/src/intl/gridlist/fi-FI.json +4 -0
- package/src/intl/gridlist/fr-FR.json +4 -0
- package/src/intl/gridlist/he-IL.json +4 -0
- package/src/intl/gridlist/hr-HR.json +4 -0
- package/src/intl/gridlist/hu-HU.json +4 -0
- package/src/intl/gridlist/index.ts +75 -0
- package/src/intl/gridlist/it-IT.json +4 -0
- package/src/intl/gridlist/ja-JP.json +4 -0
- package/src/intl/gridlist/ko-KR.json +4 -0
- package/src/intl/gridlist/lt-LT.json +4 -0
- package/src/intl/gridlist/lv-LV.json +4 -0
- package/src/intl/gridlist/nb-NO.json +4 -0
- package/src/intl/gridlist/nl-NL.json +4 -0
- package/src/intl/gridlist/pl-PL.json +4 -0
- package/src/intl/gridlist/pt-BR.json +4 -0
- package/src/intl/gridlist/pt-PT.json +4 -0
- package/src/intl/gridlist/ro-RO.json +4 -0
- package/src/intl/gridlist/ru-RU.json +4 -0
- package/src/intl/gridlist/sk-SK.json +4 -0
- package/src/intl/gridlist/sl-SI.json +4 -0
- package/src/intl/gridlist/sr-SP.json +4 -0
- package/src/intl/gridlist/sv-SE.json +4 -0
- package/src/intl/gridlist/tr-TR.json +4 -0
- package/src/intl/gridlist/uk-UA.json +4 -0
- package/src/intl/gridlist/zh-CN.json +4 -0
- package/src/intl/gridlist/zh-TW.json +4 -0
- package/src/intl/menu/ar-AE.json +3 -0
- package/src/intl/menu/bg-BG.json +3 -0
- package/src/intl/menu/cs-CZ.json +3 -0
- package/src/intl/menu/da-DK.json +3 -0
- package/src/intl/menu/de-DE.json +3 -0
- package/src/intl/menu/el-GR.json +3 -0
- package/src/intl/menu/en-US.json +3 -0
- package/src/intl/menu/es-ES.json +3 -0
- package/src/intl/menu/et-EE.json +3 -0
- package/src/intl/menu/fi-FI.json +3 -0
- package/src/intl/menu/fr-FR.json +3 -0
- package/src/intl/menu/he-IL.json +3 -0
- package/src/intl/menu/hr-HR.json +3 -0
- package/src/intl/menu/hu-HU.json +3 -0
- package/src/intl/menu/index.ts +75 -0
- package/src/intl/menu/it-IT.json +3 -0
- package/src/intl/menu/ja-JP.json +3 -0
- package/src/intl/menu/ko-KR.json +3 -0
- package/src/intl/menu/lt-LT.json +3 -0
- package/src/intl/menu/lv-LV.json +3 -0
- package/src/intl/menu/nb-NO.json +3 -0
- package/src/intl/menu/nl-NL.json +3 -0
- package/src/intl/menu/pl-PL.json +3 -0
- package/src/intl/menu/pt-BR.json +3 -0
- package/src/intl/menu/pt-PT.json +3 -0
- package/src/intl/menu/ro-RO.json +3 -0
- package/src/intl/menu/ru-RU.json +3 -0
- package/src/intl/menu/sk-SK.json +3 -0
- package/src/intl/menu/sl-SI.json +3 -0
- package/src/intl/menu/sr-SP.json +3 -0
- package/src/intl/menu/sv-SE.json +3 -0
- package/src/intl/menu/tr-TR.json +3 -0
- package/src/intl/menu/uk-UA.json +3 -0
- package/src/intl/menu/zh-CN.json +3 -0
- package/src/intl/menu/zh-TW.json +3 -0
- package/src/intl/numberfield/ar-AE.json +5 -0
- package/src/intl/numberfield/bg-BG.json +5 -0
- package/src/intl/numberfield/cs-CZ.json +5 -0
- package/src/intl/numberfield/da-DK.json +5 -0
- package/src/intl/numberfield/de-DE.json +5 -0
- package/src/intl/numberfield/el-GR.json +5 -0
- package/src/intl/numberfield/en-US.json +5 -0
- package/src/intl/numberfield/es-ES.json +5 -0
- package/src/intl/numberfield/et-EE.json +5 -0
- package/src/intl/numberfield/fi-FI.json +5 -0
- package/src/intl/numberfield/fr-FR.json +5 -0
- package/src/intl/numberfield/he-IL.json +5 -0
- package/src/intl/numberfield/hr-HR.json +5 -0
- package/src/intl/numberfield/hu-HU.json +5 -0
- package/src/intl/numberfield/index.ts +75 -0
- package/src/intl/numberfield/it-IT.json +5 -0
- package/src/intl/numberfield/ja-JP.json +5 -0
- package/src/intl/numberfield/ko-KR.json +5 -0
- package/src/intl/numberfield/lt-LT.json +5 -0
- package/src/intl/numberfield/lv-LV.json +5 -0
- package/src/intl/numberfield/nb-NO.json +5 -0
- package/src/intl/numberfield/nl-NL.json +5 -0
- package/src/intl/numberfield/pl-PL.json +5 -0
- package/src/intl/numberfield/pt-BR.json +5 -0
- package/src/intl/numberfield/pt-PT.json +5 -0
- package/src/intl/numberfield/ro-RO.json +5 -0
- package/src/intl/numberfield/ru-RU.json +5 -0
- package/src/intl/numberfield/sk-SK.json +5 -0
- package/src/intl/numberfield/sl-SI.json +5 -0
- package/src/intl/numberfield/sr-SP.json +5 -0
- package/src/intl/numberfield/sv-SE.json +5 -0
- package/src/intl/numberfield/tr-TR.json +5 -0
- package/src/intl/numberfield/uk-UA.json +5 -0
- package/src/intl/numberfield/zh-CN.json +5 -0
- package/src/intl/numberfield/zh-TW.json +5 -0
- package/src/intl/overlays/ar-AE.json +3 -0
- package/src/intl/overlays/bg-BG.json +3 -0
- package/src/intl/overlays/cs-CZ.json +3 -0
- package/src/intl/overlays/da-DK.json +3 -0
- package/src/intl/overlays/de-DE.json +3 -0
- package/src/intl/overlays/el-GR.json +3 -0
- package/src/intl/overlays/en-US.json +3 -0
- package/src/intl/overlays/es-ES.json +3 -0
- package/src/intl/overlays/et-EE.json +3 -0
- package/src/intl/overlays/fi-FI.json +3 -0
- package/src/intl/overlays/fr-FR.json +3 -0
- package/src/intl/overlays/he-IL.json +3 -0
- package/src/intl/overlays/hr-HR.json +3 -0
- package/src/intl/overlays/hu-HU.json +3 -0
- package/src/intl/overlays/index.ts +75 -0
- package/src/intl/overlays/it-IT.json +3 -0
- package/src/intl/overlays/ja-JP.json +3 -0
- package/src/intl/overlays/ko-KR.json +3 -0
- package/src/intl/overlays/lt-LT.json +3 -0
- package/src/intl/overlays/lv-LV.json +3 -0
- package/src/intl/overlays/nb-NO.json +3 -0
- package/src/intl/overlays/nl-NL.json +3 -0
- package/src/intl/overlays/pl-PL.json +3 -0
- package/src/intl/overlays/pt-BR.json +3 -0
- package/src/intl/overlays/pt-PT.json +3 -0
- package/src/intl/overlays/ro-RO.json +3 -0
- package/src/intl/overlays/ru-RU.json +3 -0
- package/src/intl/overlays/sk-SK.json +3 -0
- package/src/intl/overlays/sl-SI.json +3 -0
- package/src/intl/overlays/sr-SP.json +3 -0
- package/src/intl/overlays/sv-SE.json +3 -0
- package/src/intl/overlays/tr-TR.json +3 -0
- package/src/intl/overlays/uk-UA.json +3 -0
- package/src/intl/overlays/zh-CN.json +3 -0
- package/src/intl/overlays/zh-TW.json +3 -0
- package/src/intl/searchfield/ar-AE.json +3 -0
- package/src/intl/searchfield/bg-BG.json +3 -0
- package/src/intl/searchfield/cs-CZ.json +3 -0
- package/src/intl/searchfield/da-DK.json +3 -0
- package/src/intl/searchfield/de-DE.json +3 -0
- package/src/intl/searchfield/el-GR.json +3 -0
- package/src/intl/searchfield/en-US.json +3 -0
- package/src/intl/searchfield/es-ES.json +3 -0
- package/src/intl/searchfield/et-EE.json +3 -0
- package/src/intl/searchfield/fi-FI.json +3 -0
- package/src/intl/searchfield/fr-FR.json +3 -0
- package/src/intl/searchfield/he-IL.json +3 -0
- package/src/intl/searchfield/hr-HR.json +3 -0
- package/src/intl/searchfield/hu-HU.json +3 -0
- package/src/intl/searchfield/index.ts +75 -0
- package/src/intl/searchfield/it-IT.json +3 -0
- package/src/intl/searchfield/ja-JP.json +3 -0
- package/src/intl/searchfield/ko-KR.json +3 -0
- package/src/intl/searchfield/lt-LT.json +3 -0
- package/src/intl/searchfield/lv-LV.json +3 -0
- package/src/intl/searchfield/nb-NO.json +3 -0
- package/src/intl/searchfield/nl-NL.json +3 -0
- package/src/intl/searchfield/pl-PL.json +3 -0
- package/src/intl/searchfield/pt-BR.json +3 -0
- package/src/intl/searchfield/pt-PT.json +3 -0
- package/src/intl/searchfield/ro-RO.json +3 -0
- package/src/intl/searchfield/ru-RU.json +3 -0
- package/src/intl/searchfield/sk-SK.json +3 -0
- package/src/intl/searchfield/sl-SI.json +3 -0
- package/src/intl/searchfield/sr-SP.json +3 -0
- package/src/intl/searchfield/sv-SE.json +3 -0
- package/src/intl/searchfield/tr-TR.json +3 -0
- package/src/intl/searchfield/uk-UA.json +3 -0
- package/src/intl/searchfield/zh-CN.json +3 -0
- package/src/intl/searchfield/zh-TW.json +3 -0
- package/src/intl/spinbutton/ar-AE.json +3 -0
- package/src/intl/spinbutton/bg-BG.json +3 -0
- package/src/intl/spinbutton/cs-CZ.json +3 -0
- package/src/intl/spinbutton/da-DK.json +3 -0
- package/src/intl/spinbutton/de-DE.json +3 -0
- package/src/intl/spinbutton/el-GR.json +3 -0
- package/src/intl/spinbutton/en-US.json +3 -0
- package/src/intl/spinbutton/es-ES.json +3 -0
- package/src/intl/spinbutton/et-EE.json +3 -0
- package/src/intl/spinbutton/fi-FI.json +3 -0
- package/src/intl/spinbutton/fr-FR.json +3 -0
- package/src/intl/spinbutton/he-IL.json +3 -0
- package/src/intl/spinbutton/hr-HR.json +3 -0
- package/src/intl/spinbutton/hu-HU.json +3 -0
- package/src/intl/spinbutton/index.ts +75 -0
- package/src/intl/spinbutton/it-IT.json +3 -0
- package/src/intl/spinbutton/ja-JP.json +3 -0
- package/src/intl/spinbutton/ko-KR.json +3 -0
- package/src/intl/spinbutton/lt-LT.json +3 -0
- package/src/intl/spinbutton/lv-LV.json +3 -0
- package/src/intl/spinbutton/nb-NO.json +3 -0
- package/src/intl/spinbutton/nl-NL.json +3 -0
- package/src/intl/spinbutton/pl-PL.json +3 -0
- package/src/intl/spinbutton/pt-BR.json +3 -0
- package/src/intl/spinbutton/pt-PT.json +3 -0
- package/src/intl/spinbutton/ro-RO.json +3 -0
- package/src/intl/spinbutton/ru-RU.json +3 -0
- package/src/intl/spinbutton/sk-SK.json +3 -0
- package/src/intl/spinbutton/sl-SI.json +3 -0
- package/src/intl/spinbutton/sr-SP.json +3 -0
- package/src/intl/spinbutton/sv-SE.json +3 -0
- package/src/intl/spinbutton/tr-TR.json +3 -0
- package/src/intl/spinbutton/uk-UA.json +3 -0
- package/src/intl/spinbutton/zh-CN.json +3 -0
- package/src/intl/spinbutton/zh-TW.json +3 -0
- package/src/intl/tag/ar-AE.json +4 -0
- package/src/intl/tag/bg-BG.json +4 -0
- package/src/intl/tag/cs-CZ.json +4 -0
- package/src/intl/tag/da-DK.json +4 -0
- package/src/intl/tag/de-DE.json +4 -0
- package/src/intl/tag/el-GR.json +4 -0
- package/src/intl/tag/en-US.json +4 -0
- package/src/intl/tag/es-ES.json +4 -0
- package/src/intl/tag/et-EE.json +4 -0
- package/src/intl/tag/fi-FI.json +4 -0
- package/src/intl/tag/fr-FR.json +4 -0
- package/src/intl/tag/he-IL.json +4 -0
- package/src/intl/tag/hr-HR.json +4 -0
- package/src/intl/tag/hu-HU.json +4 -0
- package/src/intl/tag/index.ts +75 -0
- package/src/intl/tag/it-IT.json +4 -0
- package/src/intl/tag/ja-JP.json +4 -0
- package/src/intl/tag/ko-KR.json +4 -0
- package/src/intl/tag/lt-LT.json +4 -0
- package/src/intl/tag/lv-LV.json +4 -0
- package/src/intl/tag/nb-NO.json +4 -0
- package/src/intl/tag/nl-NL.json +4 -0
- package/src/intl/tag/pl-PL.json +4 -0
- package/src/intl/tag/pt-BR.json +4 -0
- package/src/intl/tag/pt-PT.json +4 -0
- package/src/intl/tag/ro-RO.json +4 -0
- package/src/intl/tag/ru-RU.json +4 -0
- package/src/intl/tag/sk-SK.json +4 -0
- package/src/intl/tag/sl-SI.json +4 -0
- package/src/intl/tag/sr-SP.json +4 -0
- package/src/intl/tag/sv-SE.json +4 -0
- package/src/intl/tag/tr-TR.json +4 -0
- package/src/intl/tag/uk-UA.json +4 -0
- package/src/intl/tag/zh-CN.json +4 -0
- package/src/intl/tag/zh-TW.json +4 -0
- package/src/label/useField.ts +67 -0
- package/src/label/useLabel.ts +78 -0
- package/src/link/useLink.ts +108 -0
- package/src/listbox/useListBox.ts +224 -0
- package/src/listbox/useListBoxSection.ts +74 -0
- package/src/listbox/useOption.ts +212 -0
- package/src/listbox/utils.ts +38 -0
- package/src/live-announcer/LiveAnnouncer.ts +172 -0
- package/src/menu/useMenu.ts +139 -0
- package/src/menu/useMenuItem.ts +453 -0
- package/src/menu/useMenuSection.ts +70 -0
- package/src/menu/useMenuTrigger.ts +189 -0
- package/src/menu/useSafelyMouseToSubmenu.ts +236 -0
- package/src/menu/useSubmenuTrigger.ts +357 -0
- package/src/menu/utils.ts +16 -0
- package/src/meter/useMeter.ts +43 -0
- package/src/numberfield/useNumberField.ts +572 -0
- package/src/overlays/DismissButton.ts +50 -0
- package/src/overlays/Overlay.ts +106 -0
- package/src/overlays/PortalProvider.ts +37 -0
- package/src/overlays/ariaHideOutside.ts +299 -0
- package/src/overlays/calculatePosition.ts +856 -0
- package/src/overlays/useCloseOnScroll.ts +75 -0
- package/src/overlays/useModal.ts +224 -0
- package/src/overlays/useModalOverlay.ts +103 -0
- package/src/overlays/useOverlay.ts +199 -0
- package/src/overlays/useOverlayPosition.ts +462 -0
- package/src/overlays/useOverlayTrigger.ts +94 -0
- package/src/overlays/usePopover.ts +170 -0
- package/src/overlays/usePreventScroll.ts +316 -0
- package/src/progress/useProgressBar.ts +115 -0
- package/src/radio/useRadio.ts +219 -0
- package/src/radio/useRadioGroup.ts +184 -0
- package/src/radio/utils.ts +15 -0
- package/src/searchfield/useSearchField.ts +156 -0
- package/src/select/HiddenSelect.ts +261 -0
- package/src/select/useSelect.ts +332 -0
- package/src/selection/DOMLayoutDelegate.ts +51 -0
- package/src/selection/ListKeyboardDelegate.ts +392 -0
- package/src/selection/useSelectableCollection.ts +750 -0
- package/src/selection/useSelectableItem.ts +499 -0
- package/src/selection/useSelectableList.ts +132 -0
- package/src/selection/useTypeSelect.ts +192 -0
- package/src/selection/utils.ts +50 -0
- package/src/separator/useSeparator.ts +41 -0
- package/src/slider/useSlider.ts +277 -0
- package/src/slider/useSliderThumb.ts +375 -0
- package/src/slider/utils.ts +20 -0
- package/src/spinbutton/useSpinButton.ts +380 -0
- package/src/stately/checkbox/useCheckboxGroupState.ts +177 -0
- package/src/stately/collections/CollectionBuilder.ts +332 -0
- package/src/stately/collections/Item.ts +78 -0
- package/src/stately/collections/Section.ts +52 -0
- package/src/stately/collections/getChildNodes.ts +94 -0
- package/src/stately/collections/getItemCount.ts +29 -0
- package/src/stately/collections/types.ts +20 -0
- package/src/stately/collections/useCollection.ts +54 -0
- package/src/stately/combobox/useComboBoxState.ts +763 -0
- package/src/stately/disclosure/useDisclosureGroupState.ts +108 -0
- package/src/stately/disclosure/useDisclosureState.ts +84 -0
- package/src/stately/form/useFormValidationState.ts +331 -0
- package/src/stately/index.ts +111 -0
- package/src/stately/list/ListCollection.ts +104 -0
- package/src/stately/list/useListState.ts +178 -0
- package/src/stately/list/useSingleSelectListState.ts +101 -0
- package/src/stately/menu/useMenuTriggerState.ts +120 -0
- package/src/stately/menu/useSubmenuTriggerState.ts +116 -0
- package/src/stately/numberfield/useNumberFieldState.ts +430 -0
- package/src/stately/overlays/useOverlayTriggerState.ts +85 -0
- package/src/stately/radio/useRadioGroupState.ts +150 -0
- package/src/stately/searchfield/useSearchFieldState.ts +79 -0
- package/src/stately/select/useSelectState.ts +322 -0
- package/src/stately/selection/Selection.ts +23 -0
- package/src/stately/selection/SelectionManager.ts +541 -0
- package/src/stately/selection/types.ts +117 -0
- package/src/stately/selection/useMultipleSelectionState.ts +178 -0
- package/src/stately/slider/useSliderState.ts +458 -0
- package/src/stately/tabs/useTabListState.ts +149 -0
- package/src/stately/toggle/useToggleGroupState.ts +109 -0
- package/src/stately/toggle/useToggleState.ts +100 -0
- package/src/stately/tooltip/useTooltipTriggerState.ts +218 -0
- package/src/stately/tree/TreeCollection.ts +92 -0
- package/src/stately/tree/useTreeState.ts +121 -0
- package/src/stately/utils/useControlledState.ts +7 -0
- package/src/switch/useSwitch.ts +77 -0
- package/src/tabs/TabsKeyboardDelegate.ts +99 -0
- package/src/tabs/useTab.ts +117 -0
- package/src/tabs/useTabList.ts +105 -0
- package/src/tabs/useTabPanel.ts +75 -0
- package/src/tabs/utils.ts +32 -0
- package/src/tag/useTag.ts +162 -0
- package/src/tag/useTagGroup.ts +192 -0
- package/src/textfield/useFormattedTextField.ts +203 -0
- package/src/textfield/useTextField.ts +248 -0
- package/src/toggle/useToggle.ts +265 -0
- package/src/toolbar/useToolbar.ts +147 -0
- package/src/tooltip/useTooltip.ts +64 -0
- package/src/tooltip/useTooltipTrigger.ts +187 -0
- package/src/utils/filterDOMProps.ts +121 -0
- package/src/utils/getScrollParent.ts +16 -0
- package/src/utils/getScrollParents.ts +20 -0
- package/src/utils/keyboard.ts +38 -0
- package/src/utils/scrollIntoView.ts +178 -0
- package/src/utils/useDeepMemo.ts +30 -0
- package/src/utils/useFormReset.ts +54 -0
- package/src/utils/useId.ts +5 -0
- package/src/utils/useLabels.ts +53 -0
- package/src/utils/useResizeObserver.ts +70 -0
- package/src/utils/useSlot.ts +78 -0
- package/src/utils/useUpdateEffect.ts +54 -0
- package/src/utils/useUpdateLayoutEffect.ts +58 -0
- package/src/visually-hidden/VisuallyHidden.ts +100 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
// Ported from react-aria (source: .react-spectrum/packages/react-aria/src/menu/useMenuItem.ts).
|
|
2
|
+
// octane adaptations:
|
|
3
|
+
// - Handlers receive NATIVE events (there is no synthetic layer): the `onClick` prop and
|
|
4
|
+
// wrapper take the native MouseEvent (upstream: React.MouseEvent); the useKeyboard
|
|
5
|
+
// handler receives the ported BaseEvent-wrapped native KeyboardEvent (which carries
|
|
6
|
+
// `continuePropagation`).
|
|
7
|
+
// - `KeyboardEvents` / `FocusEvents` are the ported NATIVE-event versions; `PressEvents`'
|
|
8
|
+
// `onClick` is re-declared natively (as in the ported useButton); `DOMAttributes` is a
|
|
9
|
+
// local structural prop-bag alias.
|
|
10
|
+
// - `TreeState` / `SelectionManager` / `getItemCount` from the ported stately sources.
|
|
11
|
+
// - Public-hook slot threading (splitSlot/subSlot) per the binding convention
|
|
12
|
+
// (`useLinkProps` composes only context-reading hooks and takes no slot, matching the
|
|
13
|
+
// ported useLink).
|
|
14
|
+
import type {
|
|
15
|
+
DOMProps,
|
|
16
|
+
FocusableElement,
|
|
17
|
+
HoverEvents,
|
|
18
|
+
Key,
|
|
19
|
+
PressEvent,
|
|
20
|
+
PressEvents,
|
|
21
|
+
RefObject,
|
|
22
|
+
} from '@react-types/shared';
|
|
23
|
+
import { filterDOMProps } from '../utils/filterDOMProps';
|
|
24
|
+
import type { FocusEvents } from '../interactions/useFocus';
|
|
25
|
+
import { getEventTarget } from '../utils/shadowdom/DOMFunctions';
|
|
26
|
+
import { getItemCount } from '../stately/collections/getItemCount';
|
|
27
|
+
import { handleLinkClick, useLinkProps, useRouter } from '../utils/openLink';
|
|
28
|
+
import { isFocusVisible, setInteractionModality } from '../interactions/useFocusVisible';
|
|
29
|
+
import type { KeyboardEvents } from '../interactions/useKeyboard';
|
|
30
|
+
import { menuData } from './utils';
|
|
31
|
+
import { mergeProps } from '../utils/mergeProps';
|
|
32
|
+
import type { SelectionManager } from '../stately/selection/SelectionManager';
|
|
33
|
+
import type { TreeState } from '../stately/tree/useTreeState';
|
|
34
|
+
import { useFocusable } from '../interactions/useFocusable';
|
|
35
|
+
import { useHover } from '../interactions/useHover';
|
|
36
|
+
import { useKeyboard } from '../interactions/useKeyboard';
|
|
37
|
+
import { usePress } from '../interactions/usePress';
|
|
38
|
+
import { useRef } from 'octane';
|
|
39
|
+
import { useSelectableItem } from '../selection/useSelectableItem';
|
|
40
|
+
import { useSlotId } from '../utils/useId';
|
|
41
|
+
|
|
42
|
+
import { S, splitSlot, subSlot } from '../internal';
|
|
43
|
+
|
|
44
|
+
// octane adaptation: minimal structural DOMAttributes (upstream's drags React's synthetic
|
|
45
|
+
// handler types along).
|
|
46
|
+
type DOMAttributes = Record<string, any>;
|
|
47
|
+
|
|
48
|
+
export interface MenuItemAria {
|
|
49
|
+
/** Props for the menu item element. */
|
|
50
|
+
menuItemProps: DOMAttributes;
|
|
51
|
+
|
|
52
|
+
/** Props for the main text element inside the menu item. */
|
|
53
|
+
labelProps: DOMAttributes;
|
|
54
|
+
|
|
55
|
+
/** Props for the description text element inside the menu item, if any. */
|
|
56
|
+
descriptionProps: DOMAttributes;
|
|
57
|
+
|
|
58
|
+
/** Props for the keyboard shortcut text element inside the item, if any. */
|
|
59
|
+
keyboardShortcutProps: DOMAttributes;
|
|
60
|
+
|
|
61
|
+
/** Whether the item is currently focused. */
|
|
62
|
+
isFocused: boolean;
|
|
63
|
+
/** Whether the item is keyboard focused. */
|
|
64
|
+
isFocusVisible: boolean;
|
|
65
|
+
/** Whether the item is currently selected. */
|
|
66
|
+
isSelected: boolean;
|
|
67
|
+
/** Whether the item is currently in a pressed state. */
|
|
68
|
+
isPressed: boolean;
|
|
69
|
+
/** Whether the item is disabled. */
|
|
70
|
+
isDisabled: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface AriaMenuItemProps
|
|
74
|
+
extends DOMProps, Omit<PressEvents, 'onClick'>, HoverEvents, KeyboardEvents, FocusEvents {
|
|
75
|
+
/**
|
|
76
|
+
* **Not recommended – use `onPress` instead.** octane adaptation: native MouseEvent
|
|
77
|
+
* (upstream's `PressEvents.onClick` is typed over React's synthetic event).
|
|
78
|
+
*/
|
|
79
|
+
onClick?: (e: MouseEvent) => void;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Whether the menu item is disabled.
|
|
83
|
+
*
|
|
84
|
+
* @deprecated - pass disabledKeys to useTreeState instead.
|
|
85
|
+
*/
|
|
86
|
+
isDisabled?: boolean;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Whether the menu item is selected.
|
|
90
|
+
*
|
|
91
|
+
* @deprecated - pass selectedKeys to useTreeState instead.
|
|
92
|
+
*/
|
|
93
|
+
isSelected?: boolean;
|
|
94
|
+
|
|
95
|
+
/** A screen reader only label for the menu item. */
|
|
96
|
+
'aria-label'?: string;
|
|
97
|
+
|
|
98
|
+
/** The unique key for the menu item. */
|
|
99
|
+
key: Key;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Handler that is called when the menu should close after selecting an item.
|
|
103
|
+
*
|
|
104
|
+
* @deprecated - pass to the menu instead.
|
|
105
|
+
*/
|
|
106
|
+
onClose?: () => void;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Whether the menu should close when the menu item is selected.
|
|
110
|
+
*
|
|
111
|
+
* @deprecated - use shouldCloseOnSelect instead.
|
|
112
|
+
*/
|
|
113
|
+
closeOnSelect?: boolean;
|
|
114
|
+
|
|
115
|
+
/** Whether the menu should close when the menu item is selected. */
|
|
116
|
+
shouldCloseOnSelect?: boolean;
|
|
117
|
+
|
|
118
|
+
/** Whether the menu item is contained in a virtual scrolling menu. */
|
|
119
|
+
isVirtualized?: boolean;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Handler that is called when the user activates the item.
|
|
123
|
+
*
|
|
124
|
+
* @deprecated - pass to the menu instead.
|
|
125
|
+
*/
|
|
126
|
+
onAction?: (key: Key) => void;
|
|
127
|
+
|
|
128
|
+
/** What kind of popup the item opens. */
|
|
129
|
+
'aria-haspopup'?: 'menu' | 'dialog';
|
|
130
|
+
|
|
131
|
+
/** Indicates whether the menu item's popup element is expanded or collapsed. */
|
|
132
|
+
'aria-expanded'?: boolean | 'true' | 'false';
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Identifies the menu item's popup element whose contents or presence is controlled by the menu
|
|
136
|
+
* item.
|
|
137
|
+
*/
|
|
138
|
+
'aria-controls'?: string;
|
|
139
|
+
|
|
140
|
+
/** Identifies the element(s) that describe the menu item. */
|
|
141
|
+
'aria-describedby'?: string;
|
|
142
|
+
|
|
143
|
+
/** Override of the selection manager. By default, `state.selectionManager` is used. */
|
|
144
|
+
selectionManager?: SelectionManager;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Provides the behavior and accessibility implementation for an item in a menu.
|
|
149
|
+
* See `useMenu` for more details about menus.
|
|
150
|
+
*
|
|
151
|
+
* @param props - Props for the item.
|
|
152
|
+
* @param state - State for the menu, as returned by `useTreeState`.
|
|
153
|
+
*/
|
|
154
|
+
export function useMenuItem<T>(
|
|
155
|
+
props: AriaMenuItemProps,
|
|
156
|
+
state: TreeState<T>,
|
|
157
|
+
ref: RefObject<FocusableElement | null>,
|
|
158
|
+
): MenuItemAria;
|
|
159
|
+
// Slot-threading form: sibling ported hooks pass their derived sub-slot as the trailing arg.
|
|
160
|
+
export function useMenuItem<T>(
|
|
161
|
+
props: AriaMenuItemProps,
|
|
162
|
+
state: TreeState<T>,
|
|
163
|
+
ref: RefObject<FocusableElement | null>,
|
|
164
|
+
slot: symbol | undefined,
|
|
165
|
+
): MenuItemAria;
|
|
166
|
+
export function useMenuItem(...args: any[]): MenuItemAria {
|
|
167
|
+
const [user, slotArg] = splitSlot(args);
|
|
168
|
+
const slot = slotArg ?? S('useMenuItem');
|
|
169
|
+
const props = user[0] as AriaMenuItemProps;
|
|
170
|
+
const state = user[1] as TreeState<unknown>;
|
|
171
|
+
const ref = user[2] as RefObject<FocusableElement | null>;
|
|
172
|
+
|
|
173
|
+
let {
|
|
174
|
+
id,
|
|
175
|
+
key,
|
|
176
|
+
closeOnSelect,
|
|
177
|
+
shouldCloseOnSelect,
|
|
178
|
+
isVirtualized,
|
|
179
|
+
'aria-haspopup': hasPopup,
|
|
180
|
+
onPressStart,
|
|
181
|
+
onPressUp: pressUpProp,
|
|
182
|
+
onPress,
|
|
183
|
+
onPressChange: pressChangeProp,
|
|
184
|
+
onPressEnd,
|
|
185
|
+
onClick: onClickProp,
|
|
186
|
+
onHoverStart: hoverStartProp,
|
|
187
|
+
onHoverChange,
|
|
188
|
+
onHoverEnd,
|
|
189
|
+
onKeyDown,
|
|
190
|
+
onKeyUp,
|
|
191
|
+
onFocus,
|
|
192
|
+
onFocusChange,
|
|
193
|
+
onBlur,
|
|
194
|
+
selectionManager = state.selectionManager,
|
|
195
|
+
} = props;
|
|
196
|
+
|
|
197
|
+
let isTrigger = !!hasPopup;
|
|
198
|
+
let isTriggerExpanded = isTrigger && props['aria-expanded'] === 'true';
|
|
199
|
+
let isDisabled = props.isDisabled ?? selectionManager.isDisabled(key);
|
|
200
|
+
let isSelected = props.isSelected ?? selectionManager.isSelected(key);
|
|
201
|
+
let data = menuData.get(state)!;
|
|
202
|
+
let item = state.collection.getItem(key);
|
|
203
|
+
let onClose = props.onClose || data.onClose;
|
|
204
|
+
let router = useRouter();
|
|
205
|
+
let performAction = () => {
|
|
206
|
+
if (isTrigger) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (item?.props?.onAction) {
|
|
211
|
+
item.props.onAction();
|
|
212
|
+
} else if (props.onAction) {
|
|
213
|
+
props.onAction(key);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (data.onAction) {
|
|
217
|
+
// Must reassign to variable otherwise `this` binding gets messed up. Something to do with WeakMap.
|
|
218
|
+
let onAction = data.onAction;
|
|
219
|
+
onAction(key, item?.value);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
let role = 'menuitem';
|
|
224
|
+
if (!isTrigger) {
|
|
225
|
+
if (selectionManager.selectionMode === 'single') {
|
|
226
|
+
role = 'menuitemradio';
|
|
227
|
+
} else if (selectionManager.selectionMode === 'multiple') {
|
|
228
|
+
role = 'menuitemcheckbox';
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
let labelId = useSlotId(undefined, subSlot(slot, 'labelId'));
|
|
233
|
+
let descriptionId = useSlotId(undefined, subSlot(slot, 'descriptionId'));
|
|
234
|
+
let keyboardId = useSlotId(undefined, subSlot(slot, 'keyboardId'));
|
|
235
|
+
|
|
236
|
+
let ariaProps: DOMAttributes = {
|
|
237
|
+
id,
|
|
238
|
+
'aria-disabled': isDisabled || undefined,
|
|
239
|
+
role,
|
|
240
|
+
'aria-label': props['aria-label'],
|
|
241
|
+
'aria-labelledby': labelId,
|
|
242
|
+
'aria-describedby':
|
|
243
|
+
[props['aria-describedby'], descriptionId, keyboardId].filter(Boolean).join(' ') || undefined,
|
|
244
|
+
'aria-controls': props['aria-controls'],
|
|
245
|
+
'aria-haspopup': hasPopup,
|
|
246
|
+
'aria-expanded': props['aria-expanded'],
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
if (selectionManager.selectionMode !== 'none' && !isTrigger) {
|
|
250
|
+
ariaProps['aria-checked'] = isSelected;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (isVirtualized) {
|
|
254
|
+
let index = Number(item?.index);
|
|
255
|
+
ariaProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;
|
|
256
|
+
ariaProps['aria-setsize'] = getItemCount(state.collection);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
let isPressedRef = useRef(false, subSlot(slot, 'isPressedRef'));
|
|
260
|
+
let onPressChange = (isPressed: boolean) => {
|
|
261
|
+
pressChangeProp?.(isPressed);
|
|
262
|
+
isPressedRef.current = isPressed;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
let interaction = useRef<{ pointerType: string; key?: string } | null>(
|
|
266
|
+
null,
|
|
267
|
+
subSlot(slot, 'interaction'),
|
|
268
|
+
);
|
|
269
|
+
let onPressUp = (e: PressEvent) => {
|
|
270
|
+
if (e.pointerType !== 'keyboard') {
|
|
271
|
+
interaction.current = { pointerType: e.pointerType };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// If interacting with mouse, allow the user to mouse down on the trigger button,
|
|
275
|
+
// drag, and release over an item (matching native behavior).
|
|
276
|
+
if (e.pointerType === 'mouse') {
|
|
277
|
+
if (!isPressedRef.current) {
|
|
278
|
+
(e.target as HTMLElement).click();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
pressUpProp?.(e);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
let onClick = (e: MouseEvent) => {
|
|
286
|
+
onClickProp?.(e);
|
|
287
|
+
performAction();
|
|
288
|
+
handleLinkClick(e, router, item!.props.href, item?.props.routerOptions);
|
|
289
|
+
|
|
290
|
+
let shouldClose =
|
|
291
|
+
interaction.current?.pointerType === 'keyboard'
|
|
292
|
+
? // Always close when pressing Enter key, or if item is not selectable.
|
|
293
|
+
interaction.current?.key === 'Enter' ||
|
|
294
|
+
selectionManager.selectionMode === 'none' ||
|
|
295
|
+
selectionManager.isLink(key)
|
|
296
|
+
: // Close except if multi-select is enabled.
|
|
297
|
+
selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key);
|
|
298
|
+
|
|
299
|
+
shouldClose = shouldCloseOnSelect ?? closeOnSelect ?? shouldClose;
|
|
300
|
+
|
|
301
|
+
if (onClose && !isTrigger && shouldClose) {
|
|
302
|
+
onClose();
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
interaction.current = null;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
let { itemProps, isFocused } = useSelectableItem(
|
|
309
|
+
{
|
|
310
|
+
id,
|
|
311
|
+
selectionManager: selectionManager,
|
|
312
|
+
key,
|
|
313
|
+
ref,
|
|
314
|
+
shouldSelectOnPressUp: true,
|
|
315
|
+
allowsDifferentPressOrigin: true,
|
|
316
|
+
// Disable all handling of links in useSelectable item
|
|
317
|
+
// because we handle it ourselves. The behavior of menus
|
|
318
|
+
// is slightly different from other collections because
|
|
319
|
+
// actions are performed on key down rather than key up.
|
|
320
|
+
linkBehavior: 'none',
|
|
321
|
+
shouldUseVirtualFocus: data.shouldUseVirtualFocus,
|
|
322
|
+
},
|
|
323
|
+
subSlot(slot, 'item'),
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
let { pressProps, isPressed } = usePress(
|
|
327
|
+
{
|
|
328
|
+
onPressStart,
|
|
329
|
+
onPress,
|
|
330
|
+
onPressUp,
|
|
331
|
+
onPressChange,
|
|
332
|
+
onPressEnd,
|
|
333
|
+
isDisabled,
|
|
334
|
+
},
|
|
335
|
+
subSlot(slot, 'press'),
|
|
336
|
+
);
|
|
337
|
+
let { hoverProps } = useHover(
|
|
338
|
+
{
|
|
339
|
+
isDisabled,
|
|
340
|
+
onHoverStart(e) {
|
|
341
|
+
// Hovering over an already expanded sub dialog trigger should keep focus in the dialog.
|
|
342
|
+
if (!isFocusVisible() && !(isTriggerExpanded && hasPopup)) {
|
|
343
|
+
selectionManager.setFocused(true);
|
|
344
|
+
selectionManager.setFocusedKey(key);
|
|
345
|
+
}
|
|
346
|
+
hoverStartProp?.(e);
|
|
347
|
+
},
|
|
348
|
+
onHoverChange,
|
|
349
|
+
onHoverEnd,
|
|
350
|
+
},
|
|
351
|
+
subSlot(slot, 'hover'),
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
let { keyboardProps } = useKeyboard(
|
|
355
|
+
{
|
|
356
|
+
onKeyDown: (e) => {
|
|
357
|
+
// Ignore repeating events, which may have started on the menu trigger before moving
|
|
358
|
+
// focus to the menu item. We want to wait for a second complete key press sequence.
|
|
359
|
+
if (e.repeat) {
|
|
360
|
+
e.continuePropagation();
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
switch (e.key) {
|
|
365
|
+
case ' ':
|
|
366
|
+
interaction.current = { pointerType: 'keyboard', key: ' ' };
|
|
367
|
+
(getEventTarget(e) as HTMLElement).click();
|
|
368
|
+
|
|
369
|
+
// click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
|
|
370
|
+
// to the newly opened submenu's first item.
|
|
371
|
+
setInteractionModality('keyboard');
|
|
372
|
+
break;
|
|
373
|
+
case 'Enter':
|
|
374
|
+
interaction.current = { pointerType: 'keyboard', key: 'Enter' };
|
|
375
|
+
|
|
376
|
+
// Trigger click unless this is a link. Links trigger click natively.
|
|
377
|
+
if ((getEventTarget(e) as HTMLElement).tagName !== 'A') {
|
|
378
|
+
(getEventTarget(e) as HTMLElement).click();
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
|
|
382
|
+
// to the newly opened submenu's first item.
|
|
383
|
+
setInteractionModality('keyboard');
|
|
384
|
+
break;
|
|
385
|
+
default:
|
|
386
|
+
if (!isTrigger) {
|
|
387
|
+
e.continuePropagation();
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
onKeyDown?.(e);
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
onKeyUp,
|
|
395
|
+
},
|
|
396
|
+
subSlot(slot, 'keyboard'),
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
let { focusableProps } = useFocusable(
|
|
400
|
+
{ onBlur, onFocus, onFocusChange },
|
|
401
|
+
ref,
|
|
402
|
+
subSlot(slot, 'focusable'),
|
|
403
|
+
);
|
|
404
|
+
let domProps = filterDOMProps(item?.props);
|
|
405
|
+
delete domProps.id;
|
|
406
|
+
let linkProps = useLinkProps(item?.props);
|
|
407
|
+
|
|
408
|
+
return {
|
|
409
|
+
menuItemProps: {
|
|
410
|
+
...ariaProps,
|
|
411
|
+
...mergeProps(
|
|
412
|
+
domProps,
|
|
413
|
+
linkProps,
|
|
414
|
+
isTrigger
|
|
415
|
+
? {
|
|
416
|
+
onFocus: itemProps.onFocus,
|
|
417
|
+
'data-collection': itemProps['data-collection'],
|
|
418
|
+
'data-key': itemProps['data-key'],
|
|
419
|
+
}
|
|
420
|
+
: itemProps,
|
|
421
|
+
pressProps,
|
|
422
|
+
hoverProps,
|
|
423
|
+
keyboardProps,
|
|
424
|
+
focusableProps,
|
|
425
|
+
// Prevent DOM focus from moving on mouse down when using virtual focus or this is a submenu/subdialog trigger.
|
|
426
|
+
data.shouldUseVirtualFocus || isTrigger
|
|
427
|
+
? { onMouseDown: (e: MouseEvent) => e.preventDefault() }
|
|
428
|
+
: undefined,
|
|
429
|
+
isDisabled ? undefined : { onClick },
|
|
430
|
+
),
|
|
431
|
+
// If a submenu is expanded, set the tabIndex to -1 so that shift tabbing goes out of the menu instead of the parent menu item.
|
|
432
|
+
tabIndex:
|
|
433
|
+
itemProps.tabIndex != null && isTriggerExpanded && !data.shouldUseVirtualFocus
|
|
434
|
+
? -1
|
|
435
|
+
: itemProps.tabIndex,
|
|
436
|
+
},
|
|
437
|
+
labelProps: {
|
|
438
|
+
id: labelId,
|
|
439
|
+
},
|
|
440
|
+
descriptionProps: {
|
|
441
|
+
id: descriptionId,
|
|
442
|
+
},
|
|
443
|
+
keyboardShortcutProps: {
|
|
444
|
+
id: keyboardId,
|
|
445
|
+
},
|
|
446
|
+
isFocused,
|
|
447
|
+
isFocusVisible:
|
|
448
|
+
isFocused && selectionManager.isFocused && isFocusVisible() && !isTriggerExpanded,
|
|
449
|
+
isSelected,
|
|
450
|
+
isPressed,
|
|
451
|
+
isDisabled,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Ported from react-aria (source: .react-spectrum/packages/react-aria/src/menu/useMenuSection.ts).
|
|
2
|
+
// octane adaptations: `ReactNode` heading → `any` (octane descriptors); `DOMAttributes` is
|
|
3
|
+
// a local structural prop-bag alias; public-hook slot threading (splitSlot/subSlot) per the
|
|
4
|
+
// binding convention.
|
|
5
|
+
import { useId } from '../utils/useId';
|
|
6
|
+
|
|
7
|
+
import { S, splitSlot, subSlot } from '../internal';
|
|
8
|
+
|
|
9
|
+
// octane adaptation: minimal structural DOMAttributes (upstream's drags React's synthetic
|
|
10
|
+
// handler types along).
|
|
11
|
+
type DOMAttributes = Record<string, any>;
|
|
12
|
+
|
|
13
|
+
export interface AriaMenuSectionProps {
|
|
14
|
+
/** The heading for the section. */
|
|
15
|
+
heading?: any;
|
|
16
|
+
/** An accessibility label for the section. Required if `heading` is not present. */
|
|
17
|
+
'aria-label'?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface MenuSectionAria {
|
|
21
|
+
/** Props for the wrapper list item. */
|
|
22
|
+
itemProps: DOMAttributes;
|
|
23
|
+
|
|
24
|
+
/** Props for the heading element, if any. */
|
|
25
|
+
headingProps: DOMAttributes;
|
|
26
|
+
|
|
27
|
+
/** Props for the group element. */
|
|
28
|
+
groupProps: DOMAttributes;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Provides the behavior and accessibility implementation for a section in a menu.
|
|
33
|
+
* See `useMenu` for more details about menus.
|
|
34
|
+
*
|
|
35
|
+
* @param props - Props for the section.
|
|
36
|
+
*/
|
|
37
|
+
export function useMenuSection(props: AriaMenuSectionProps): MenuSectionAria;
|
|
38
|
+
// Slot-threading form: sibling ported hooks pass their derived sub-slot as the trailing arg.
|
|
39
|
+
export function useMenuSection(
|
|
40
|
+
props: AriaMenuSectionProps,
|
|
41
|
+
slot: symbol | undefined,
|
|
42
|
+
): MenuSectionAria;
|
|
43
|
+
export function useMenuSection(...args: any[]): MenuSectionAria {
|
|
44
|
+
const [user, slotArg] = splitSlot(args);
|
|
45
|
+
const slot = slotArg ?? S('useMenuSection');
|
|
46
|
+
const props = user[0] as AriaMenuSectionProps;
|
|
47
|
+
|
|
48
|
+
let { heading, 'aria-label': ariaLabel } = props;
|
|
49
|
+
let headingId = useId(subSlot(slot, 'headingId'));
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
itemProps: {
|
|
53
|
+
role: 'presentation',
|
|
54
|
+
},
|
|
55
|
+
headingProps: heading
|
|
56
|
+
? {
|
|
57
|
+
// Techincally, menus cannot contain headings according to ARIA.
|
|
58
|
+
// We hide the heading from assistive technology, using role="presentation",
|
|
59
|
+
// and only use it as a label for the nested group.
|
|
60
|
+
id: headingId,
|
|
61
|
+
role: 'presentation',
|
|
62
|
+
}
|
|
63
|
+
: {},
|
|
64
|
+
groupProps: {
|
|
65
|
+
role: 'group',
|
|
66
|
+
'aria-label': ariaLabel,
|
|
67
|
+
'aria-labelledby': heading ? headingId : undefined,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|