@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,170 @@
|
|
|
1
|
+
// Ported from react-aria (source: .react-spectrum/packages/react-aria/src/overlays/usePopover.ts).
|
|
2
|
+
// octane adaptations: `DOMAttributes` is a local structural prop-bag alias; public-hook slot
|
|
3
|
+
// threading (splitSlot/subSlot) per the binding convention — the composed ported hooks
|
|
4
|
+
// (useOverlay/useOverlayPosition/usePreventScroll) each receive a derived sub-slot; the explicit
|
|
5
|
+
// dependency array is kept verbatim; `OverlayTriggerState` from the ported stately overlays state;
|
|
6
|
+
// element types → `any`.
|
|
7
|
+
import { ariaHideOutside, keepVisible } from './ariaHideOutside';
|
|
8
|
+
import { AriaPositionProps, PlacementAxis, useOverlayPosition } from './useOverlayPosition';
|
|
9
|
+
import type { RefObject } from '@react-types/shared';
|
|
10
|
+
import { mergeProps } from '../utils/mergeProps';
|
|
11
|
+
import type { OverlayTriggerState } from '../stately/overlays/useOverlayTriggerState';
|
|
12
|
+
import { useEffect } from 'octane';
|
|
13
|
+
import { useOverlay } from './useOverlay';
|
|
14
|
+
import { usePreventScroll } from './usePreventScroll';
|
|
15
|
+
|
|
16
|
+
import { S, splitSlot, subSlot } from '../internal';
|
|
17
|
+
|
|
18
|
+
// octane adaptation: minimal structural DOMAttributes (upstream's drags React's synthetic
|
|
19
|
+
// handler types along).
|
|
20
|
+
type DOMAttributes = Record<string, any>;
|
|
21
|
+
|
|
22
|
+
export interface AriaPopoverProps extends Omit<
|
|
23
|
+
AriaPositionProps,
|
|
24
|
+
'isOpen' | 'onClose' | 'targetRef' | 'overlayRef'
|
|
25
|
+
> {
|
|
26
|
+
/**
|
|
27
|
+
* The ref for the element which the popover positions itself with respect to.
|
|
28
|
+
*/
|
|
29
|
+
triggerRef: RefObject<Element | null>;
|
|
30
|
+
/**
|
|
31
|
+
* The ref for the popover element.
|
|
32
|
+
*/
|
|
33
|
+
popoverRef: RefObject<Element | null>;
|
|
34
|
+
/** A ref for the popover arrow element. */
|
|
35
|
+
arrowRef?: RefObject<Element | null>;
|
|
36
|
+
/**
|
|
37
|
+
* An optional ref for a group of popovers, e.g. submenus.
|
|
38
|
+
* When provided, this element is used to detect outside interactions
|
|
39
|
+
* and hiding elements from assistive technologies instead of the popoverRef.
|
|
40
|
+
*/
|
|
41
|
+
groupRef?: RefObject<Element | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the popover is non-modal, i.e. elements outside the popover may be
|
|
44
|
+
* interacted with by assistive technologies.
|
|
45
|
+
*
|
|
46
|
+
* Most popovers should not use this option as it may negatively impact the screen
|
|
47
|
+
* reader experience. Only use with components such as combobox, which are designed
|
|
48
|
+
* to handle this situation carefully.
|
|
49
|
+
*/
|
|
50
|
+
isNonModal?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Whether pressing the escape key to close the popover should be disabled.
|
|
53
|
+
*
|
|
54
|
+
* Most popovers should not use this option. When set to true, an alternative
|
|
55
|
+
* way to close the popover with a keyboard must be provided.
|
|
56
|
+
*
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
isKeyboardDismissDisabled?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* When user interacts with the argument element outside of the popover ref,
|
|
62
|
+
* return true if onClose should be called. This gives you a chance to filter
|
|
63
|
+
* out interaction with elements that should not dismiss the popover.
|
|
64
|
+
* By default, onClose will always be called on interaction outside the popover ref.
|
|
65
|
+
*/
|
|
66
|
+
shouldCloseOnInteractOutside?: (element: Element) => boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface PopoverAria {
|
|
70
|
+
/** Props for the popover element. */
|
|
71
|
+
popoverProps: DOMAttributes;
|
|
72
|
+
/** Props for the popover tip arrow if any. */
|
|
73
|
+
arrowProps: DOMAttributes;
|
|
74
|
+
/** Props to apply to the underlay element, if any. */
|
|
75
|
+
underlayProps: DOMAttributes;
|
|
76
|
+
/** Placement of the popover with respect to the trigger. */
|
|
77
|
+
placement: PlacementAxis | null;
|
|
78
|
+
/** The origin of the target in the overlay's coordinate system. Useful for animations. */
|
|
79
|
+
triggerAnchorPoint: { x: number; y: number } | null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Provides the behavior and accessibility implementation for a popover component.
|
|
84
|
+
* A popover is an overlay element positioned relative to a trigger.
|
|
85
|
+
*/
|
|
86
|
+
export function usePopover(props: AriaPopoverProps, state: OverlayTriggerState): PopoverAria;
|
|
87
|
+
// Slot-threading form: sibling ported hooks pass their derived sub-slot as the trailing arg.
|
|
88
|
+
export function usePopover(
|
|
89
|
+
props: AriaPopoverProps,
|
|
90
|
+
state: OverlayTriggerState,
|
|
91
|
+
slot: symbol | undefined,
|
|
92
|
+
): PopoverAria;
|
|
93
|
+
export function usePopover(...args: any[]): PopoverAria {
|
|
94
|
+
const [user, slotArg] = splitSlot(args);
|
|
95
|
+
const slot = slotArg ?? S('usePopover');
|
|
96
|
+
const props = user[0] as AriaPopoverProps;
|
|
97
|
+
const state = user[1] as OverlayTriggerState;
|
|
98
|
+
|
|
99
|
+
let {
|
|
100
|
+
triggerRef,
|
|
101
|
+
popoverRef,
|
|
102
|
+
groupRef,
|
|
103
|
+
isNonModal,
|
|
104
|
+
isKeyboardDismissDisabled,
|
|
105
|
+
shouldCloseOnInteractOutside,
|
|
106
|
+
...otherProps
|
|
107
|
+
} = props;
|
|
108
|
+
|
|
109
|
+
let isSubmenu = (otherProps as any)['trigger'] === 'SubmenuTrigger';
|
|
110
|
+
|
|
111
|
+
let { overlayProps, underlayProps } = useOverlay(
|
|
112
|
+
{
|
|
113
|
+
isOpen: state.isOpen,
|
|
114
|
+
onClose: state.close,
|
|
115
|
+
shouldCloseOnBlur: true,
|
|
116
|
+
isDismissable: !isNonModal || isSubmenu,
|
|
117
|
+
isKeyboardDismissDisabled,
|
|
118
|
+
shouldCloseOnInteractOutside,
|
|
119
|
+
},
|
|
120
|
+
groupRef ?? popoverRef,
|
|
121
|
+
subSlot(slot, 'overlay'),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
let {
|
|
125
|
+
overlayProps: positionProps,
|
|
126
|
+
arrowProps,
|
|
127
|
+
placement,
|
|
128
|
+
triggerAnchorPoint: origin,
|
|
129
|
+
} = useOverlayPosition(
|
|
130
|
+
{
|
|
131
|
+
...otherProps,
|
|
132
|
+
targetRef: triggerRef,
|
|
133
|
+
overlayRef: popoverRef,
|
|
134
|
+
isOpen: state.isOpen,
|
|
135
|
+
onClose: isNonModal && !isSubmenu ? state.close : null,
|
|
136
|
+
},
|
|
137
|
+
subSlot(slot, 'position'),
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
usePreventScroll(
|
|
141
|
+
{
|
|
142
|
+
isDisabled: isNonModal || !state.isOpen,
|
|
143
|
+
},
|
|
144
|
+
subSlot(slot, 'preventScroll'),
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
useEffect(
|
|
148
|
+
() => {
|
|
149
|
+
if (state.isOpen && popoverRef.current) {
|
|
150
|
+
if (isNonModal) {
|
|
151
|
+
return keepVisible(groupRef?.current ?? popoverRef.current);
|
|
152
|
+
} else {
|
|
153
|
+
return ariaHideOutside([groupRef?.current ?? popoverRef.current], {
|
|
154
|
+
shouldUseInert: true,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
[isNonModal, state.isOpen, popoverRef, groupRef],
|
|
160
|
+
subSlot(slot, 'hideOutside'),
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
popoverProps: mergeProps(overlayProps, positionProps),
|
|
165
|
+
arrowProps,
|
|
166
|
+
underlayProps,
|
|
167
|
+
placement,
|
|
168
|
+
triggerAnchorPoint: origin,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
// Ported from react-aria (source: .react-spectrum/packages/react-aria/src/overlays/usePreventScroll.ts).
|
|
2
|
+
// octane adaptations: public-hook slot threading (splitSlot/subSlot) per the binding
|
|
3
|
+
// convention; the explicit `[isDisabled]` dependency array is kept verbatim; `setStyle`'s
|
|
4
|
+
// string-indexed style access stays `any` (untyped in upstream too). The module-level
|
|
5
|
+
// counter/restore state and the mobile-Safari branch are ported verbatim.
|
|
6
|
+
import { chain } from '../utils/chain';
|
|
7
|
+
|
|
8
|
+
import { getActiveElement, getEventTarget } from '../utils/shadowdom/DOMFunctions';
|
|
9
|
+
import { getNonce } from '../utils/getNonce';
|
|
10
|
+
import { getScrollParent } from '../utils/getScrollParent';
|
|
11
|
+
import { isIOS } from '../utils/platform';
|
|
12
|
+
import { isScrollable } from '../utils/isScrollable';
|
|
13
|
+
import { useLayoutEffect } from '../utils/useLayoutEffect';
|
|
14
|
+
import { willOpenKeyboard } from '../utils/keyboard';
|
|
15
|
+
|
|
16
|
+
import { S, splitSlot, subSlot } from '../internal';
|
|
17
|
+
|
|
18
|
+
interface PreventScrollOptions {
|
|
19
|
+
/** Whether the scroll lock is disabled. */
|
|
20
|
+
isDisabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const visualViewport = typeof document !== 'undefined' && window.visualViewport;
|
|
24
|
+
|
|
25
|
+
// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
|
|
26
|
+
let preventScrollCount = 0;
|
|
27
|
+
let restore: () => void;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Prevents scrolling on the document body on mount, and
|
|
31
|
+
* restores it on unmount. Also ensures that content does not
|
|
32
|
+
* shift due to the scrollbars disappearing.
|
|
33
|
+
*/
|
|
34
|
+
export function usePreventScroll(options?: PreventScrollOptions): void;
|
|
35
|
+
// Slot-threading form: sibling ported hooks pass their derived sub-slot as the trailing arg.
|
|
36
|
+
export function usePreventScroll(
|
|
37
|
+
options: PreventScrollOptions | undefined,
|
|
38
|
+
slot: symbol | undefined,
|
|
39
|
+
): void;
|
|
40
|
+
export function usePreventScroll(...args: any[]): void {
|
|
41
|
+
const [user, slotArg] = splitSlot(args);
|
|
42
|
+
const slot = slotArg ?? S('usePreventScroll');
|
|
43
|
+
const options = (user[0] as PreventScrollOptions | undefined) ?? {};
|
|
44
|
+
|
|
45
|
+
let { isDisabled } = options;
|
|
46
|
+
|
|
47
|
+
useLayoutEffect(
|
|
48
|
+
() => {
|
|
49
|
+
if (isDisabled) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
preventScrollCount++;
|
|
54
|
+
if (preventScrollCount === 1) {
|
|
55
|
+
if (isIOS()) {
|
|
56
|
+
restore = preventScrollMobileSafari();
|
|
57
|
+
} else {
|
|
58
|
+
restore = preventScrollStandard();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return () => {
|
|
63
|
+
preventScrollCount--;
|
|
64
|
+
if (preventScrollCount === 0) {
|
|
65
|
+
restore();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
[isDisabled],
|
|
70
|
+
subSlot(slot, 'preventScroll'),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// For most browsers, all we need to do is set `overflow: hidden` on the root element, and
|
|
75
|
+
// add some padding to prevent the page from shifting when the scrollbar is hidden.
|
|
76
|
+
function preventScrollStandard() {
|
|
77
|
+
let scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
78
|
+
return chain(
|
|
79
|
+
scrollbarWidth > 0 &&
|
|
80
|
+
// Use scrollbar-gutter when supported because it also works for fixed positioned elements.
|
|
81
|
+
('scrollbarGutter' in document.documentElement.style
|
|
82
|
+
? setStyle(document.documentElement, 'scrollbarGutter', 'stable')
|
|
83
|
+
: setStyle(document.documentElement, 'paddingRight', `${scrollbarWidth}px`)),
|
|
84
|
+
setStyle(document.documentElement, 'overflow', 'hidden'),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Mobile Safari is a whole different beast. Even with overflow: hidden,
|
|
89
|
+
// it still scrolls the page in many situations:
|
|
90
|
+
//
|
|
91
|
+
// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.
|
|
92
|
+
// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of
|
|
93
|
+
// it, so it becomes scrollable.
|
|
94
|
+
// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.
|
|
95
|
+
// This may cause even fixed position elements to scroll off the screen.
|
|
96
|
+
// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always
|
|
97
|
+
// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.
|
|
98
|
+
//
|
|
99
|
+
// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:
|
|
100
|
+
//
|
|
101
|
+
// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling
|
|
102
|
+
// on the window.
|
|
103
|
+
// 2. Set `overscroll-behavior: contain` on nested scrollable regions so they do not scroll the page when at
|
|
104
|
+
// the top or bottom. Work around a bug where this does not work when the element does not actually overflow
|
|
105
|
+
// by preventing default in a `touchmove` event. This is best effort: we can't prevent default when pinch
|
|
106
|
+
// zooming or when an element contains text selection, which may allow scrolling in some cases.
|
|
107
|
+
// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.
|
|
108
|
+
// 4. When focus moves to an input, create an off screen input and focus that temporarily. This prevents
|
|
109
|
+
// Safari from scrolling the page. After a small delay, focus the real input and scroll it into view
|
|
110
|
+
// ourselves, without scrolling the whole page.
|
|
111
|
+
function preventScrollMobileSafari() {
|
|
112
|
+
// Set overflow hidden so scrollIntoViewport() (useSelectableCollection) sees isScrollPrevented and
|
|
113
|
+
// scrolls only scroll parents instead of calling native scrollIntoView() which moves the window.
|
|
114
|
+
let restoreOverflow = setStyle(document.documentElement, 'overflow', 'hidden');
|
|
115
|
+
|
|
116
|
+
let scrollable: Element;
|
|
117
|
+
let allowTouchMove = false;
|
|
118
|
+
let onTouchStart = (e: TouchEvent) => {
|
|
119
|
+
// Store the nearest scrollable parent element from the element that the user touched.
|
|
120
|
+
let target = getEventTarget(e) as Element;
|
|
121
|
+
scrollable = isScrollable(target) ? target : getScrollParent(target, true);
|
|
122
|
+
allowTouchMove = false;
|
|
123
|
+
|
|
124
|
+
// If the target is selected, don't preventDefault in touchmove to allow user to adjust selection.
|
|
125
|
+
let selection = target.ownerDocument.defaultView!.getSelection();
|
|
126
|
+
if (selection && !selection.isCollapsed && selection.containsNode(target, true)) {
|
|
127
|
+
allowTouchMove = true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// If this is a range input, allow touch move to allow user to adjust the slider value
|
|
131
|
+
if (e.composedPath().some((el) => el instanceof HTMLInputElement && el.type === 'range')) {
|
|
132
|
+
allowTouchMove = true;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// If this is a focused input element with a selected range, allow user to drag the selection handles.
|
|
136
|
+
if (
|
|
137
|
+
'selectionStart' in target &&
|
|
138
|
+
'selectionEnd' in target &&
|
|
139
|
+
((target as any).selectionStart as number) < ((target as any).selectionEnd as number) &&
|
|
140
|
+
target.ownerDocument.activeElement === target
|
|
141
|
+
) {
|
|
142
|
+
allowTouchMove = true;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Prevent scrolling up when at the top and scrolling down when at the bottom
|
|
147
|
+
// of a nested scrollable area, otherwise mobile Safari will start scrolling
|
|
148
|
+
// the window instead.
|
|
149
|
+
// This must be applied before the touchstart event as of iOS 26, so inject it as a <style> element.
|
|
150
|
+
let style = document.createElement('style');
|
|
151
|
+
let nonce = getNonce();
|
|
152
|
+
if (nonce) {
|
|
153
|
+
style.nonce = nonce;
|
|
154
|
+
}
|
|
155
|
+
style.textContent = `
|
|
156
|
+
@layer {
|
|
157
|
+
* {
|
|
158
|
+
overscroll-behavior: contain;
|
|
159
|
+
}
|
|
160
|
+
}`.trim();
|
|
161
|
+
document.head.prepend(style);
|
|
162
|
+
|
|
163
|
+
let onTouchMove = (e: TouchEvent) => {
|
|
164
|
+
// Allow pinch-zooming.
|
|
165
|
+
if (e.touches.length === 2 || allowTouchMove) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Prevent scrolling the window.
|
|
170
|
+
if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// overscroll-behavior should prevent scroll chaining, but currently does not
|
|
176
|
+
// if the element doesn't actually overflow. https://bugs.webkit.org/show_bug.cgi?id=243452
|
|
177
|
+
// This checks that both the width and height do not overflow, otherwise we might
|
|
178
|
+
// block horizontal scrolling too. In that case, adding `touch-action: pan-x` to
|
|
179
|
+
// the element will prevent vertical page scrolling. We can't add that automatically
|
|
180
|
+
// because it must be set before the touchstart event.
|
|
181
|
+
if (
|
|
182
|
+
scrollable.scrollHeight === scrollable.clientHeight &&
|
|
183
|
+
scrollable.scrollWidth === scrollable.clientWidth
|
|
184
|
+
) {
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
let onBlur = (e: FocusEvent) => {
|
|
190
|
+
let target = getEventTarget(e) as HTMLElement;
|
|
191
|
+
let relatedTarget = e.relatedTarget as HTMLElement | null;
|
|
192
|
+
if (relatedTarget && willOpenKeyboard(relatedTarget)) {
|
|
193
|
+
// Focus without scrolling the whole page, and then scroll into view manually.
|
|
194
|
+
relatedTarget.focus({ preventScroll: true });
|
|
195
|
+
scrollIntoViewWhenReady(relatedTarget, willOpenKeyboard(target));
|
|
196
|
+
} else if (!relatedTarget) {
|
|
197
|
+
// When tapping the Done button on the keyboard, focus moves to the body.
|
|
198
|
+
// FocusScope will then restore focus back to the input. Later when tapping
|
|
199
|
+
// the same input again, it is already focused, so no blur event will fire,
|
|
200
|
+
// resulting in the flow above never running and Safari's native scrolling occurring.
|
|
201
|
+
// Instead, move focus to the parent focusable element (e.g. the dialog).
|
|
202
|
+
let focusable = target.parentElement?.closest('[tabindex]') as HTMLElement | null;
|
|
203
|
+
focusable?.focus({ preventScroll: true });
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// Override programmatic focus to scroll into view without scrolling the whole page.
|
|
208
|
+
let focus = HTMLElement.prototype.focus;
|
|
209
|
+
HTMLElement.prototype.focus = function (opts) {
|
|
210
|
+
// Track whether the keyboard was already visible before.
|
|
211
|
+
let activeElement = getActiveElement();
|
|
212
|
+
let wasKeyboardVisible = activeElement != null && willOpenKeyboard(activeElement);
|
|
213
|
+
|
|
214
|
+
// Focus the element without scrolling the page.
|
|
215
|
+
focus.call(this, { ...opts, preventScroll: true });
|
|
216
|
+
|
|
217
|
+
if (!opts || !opts.preventScroll) {
|
|
218
|
+
scrollIntoViewWhenReady(this, wasKeyboardVisible);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
let removeEvents = chain(
|
|
223
|
+
addEvent(document, 'touchstart', onTouchStart, { passive: false, capture: true }),
|
|
224
|
+
addEvent(document, 'touchmove', onTouchMove, { passive: false, capture: true }),
|
|
225
|
+
addEvent(document, 'blur', onBlur, true),
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
return () => {
|
|
229
|
+
restoreOverflow();
|
|
230
|
+
removeEvents();
|
|
231
|
+
style.remove();
|
|
232
|
+
HTMLElement.prototype.focus = focus;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Sets a CSS property on an element, and returns a function to revert it to the previous value.
|
|
237
|
+
function setStyle(element: HTMLElement, style: string, value: string) {
|
|
238
|
+
let cur = (element.style as any)[style];
|
|
239
|
+
(element.style as any)[style] = value;
|
|
240
|
+
|
|
241
|
+
return () => {
|
|
242
|
+
(element.style as any)[style] = cur;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Adds an event listener to an element, and returns a function to remove it.
|
|
247
|
+
function addEvent<K extends keyof GlobalEventHandlersEventMap>(
|
|
248
|
+
target: Document | Window,
|
|
249
|
+
event: K,
|
|
250
|
+
handler: (this: Document | Window, ev: GlobalEventHandlersEventMap[K]) => any,
|
|
251
|
+
options?: boolean | AddEventListenerOptions,
|
|
252
|
+
) {
|
|
253
|
+
// internal function, so it's ok to ignore the difficult to fix type error
|
|
254
|
+
// @ts-ignore
|
|
255
|
+
target.addEventListener(event, handler, options);
|
|
256
|
+
return () => {
|
|
257
|
+
// @ts-ignore
|
|
258
|
+
target.removeEventListener(event, handler, options);
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function scrollIntoViewWhenReady(target: Element, wasKeyboardVisible: boolean) {
|
|
263
|
+
if (wasKeyboardVisible || !visualViewport) {
|
|
264
|
+
// If the keyboard was already visible, scroll the target into view immediately.
|
|
265
|
+
scrollIntoView(target);
|
|
266
|
+
} else {
|
|
267
|
+
// Otherwise, wait for the visual viewport to resize before scrolling so we can
|
|
268
|
+
// measure the correct position to scroll to.
|
|
269
|
+
visualViewport.addEventListener('resize', () => scrollIntoView(target), { once: true });
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function scrollIntoView(target: Element) {
|
|
274
|
+
let root = document.scrollingElement || document.documentElement;
|
|
275
|
+
let nextTarget: Element | null = target;
|
|
276
|
+
while (nextTarget && nextTarget !== root) {
|
|
277
|
+
// Find the parent scrollable element and adjust the scroll position if the target is not already in view.
|
|
278
|
+
let scrollable = getScrollParent(nextTarget);
|
|
279
|
+
if (
|
|
280
|
+
scrollable !== document.documentElement &&
|
|
281
|
+
scrollable !== document.body &&
|
|
282
|
+
scrollable !== nextTarget
|
|
283
|
+
) {
|
|
284
|
+
let scrollableRect = scrollable.getBoundingClientRect();
|
|
285
|
+
let targetRect = nextTarget.getBoundingClientRect();
|
|
286
|
+
if (
|
|
287
|
+
targetRect.top < scrollableRect.top ||
|
|
288
|
+
targetRect.bottom > scrollableRect.top + nextTarget.clientHeight
|
|
289
|
+
) {
|
|
290
|
+
let bottom = scrollableRect.bottom;
|
|
291
|
+
if (visualViewport) {
|
|
292
|
+
bottom = Math.min(bottom, visualViewport.offsetTop + visualViewport.height);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Center within the viewport.
|
|
296
|
+
let adjustment =
|
|
297
|
+
targetRect.top -
|
|
298
|
+
scrollableRect.top -
|
|
299
|
+
((bottom - scrollableRect.top) / 2 - targetRect.height / 2);
|
|
300
|
+
scrollable.scrollTo({
|
|
301
|
+
// Clamp to the valid range to prevent over-scrolling.
|
|
302
|
+
top: Math.max(
|
|
303
|
+
0,
|
|
304
|
+
Math.min(
|
|
305
|
+
scrollable.scrollHeight - scrollable.clientHeight,
|
|
306
|
+
scrollable.scrollTop + adjustment,
|
|
307
|
+
),
|
|
308
|
+
),
|
|
309
|
+
behavior: 'smooth',
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
nextTarget = scrollable.parentElement;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// Ported from react-aria (source: .react-spectrum/packages/react-aria/src/progress/useProgressBar.ts).
|
|
2
|
+
// octane adaptations: ReactNode → any (octane renderables); public-hook slot threading.
|
|
3
|
+
import type { AriaLabelingProps, DOMAttributes, DOMProps } from '@react-types/shared';
|
|
4
|
+
|
|
5
|
+
import { S, splitSlot, subSlot } from '../internal';
|
|
6
|
+
import { clamp } from '../stately/utils/number';
|
|
7
|
+
import { filterDOMProps } from '../utils/filterDOMProps';
|
|
8
|
+
import { mergeProps } from '../utils/mergeProps';
|
|
9
|
+
import { useLabel } from '../label/useLabel';
|
|
10
|
+
import { useNumberFormatter } from '../i18n/useNumberFormatter';
|
|
11
|
+
|
|
12
|
+
export interface ProgressBarBaseProps {
|
|
13
|
+
/**
|
|
14
|
+
* The current value (controlled).
|
|
15
|
+
*
|
|
16
|
+
* @default 0
|
|
17
|
+
*/
|
|
18
|
+
value?: number;
|
|
19
|
+
/**
|
|
20
|
+
* The smallest value allowed for the input.
|
|
21
|
+
*
|
|
22
|
+
* @default 0
|
|
23
|
+
*/
|
|
24
|
+
minValue?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The largest value allowed for the input.
|
|
27
|
+
*
|
|
28
|
+
* @default 100
|
|
29
|
+
*/
|
|
30
|
+
maxValue?: number;
|
|
31
|
+
/** The content to display as the label. */
|
|
32
|
+
label?: any;
|
|
33
|
+
/**
|
|
34
|
+
* The display format of the value label.
|
|
35
|
+
*
|
|
36
|
+
* @default { style: 'percent' }
|
|
37
|
+
*/
|
|
38
|
+
formatOptions?: Intl.NumberFormatOptions;
|
|
39
|
+
/** The content to display as the value's label (e.g. 1 of 4). */
|
|
40
|
+
valueLabel?: any;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface AriaProgressBarBaseProps
|
|
44
|
+
extends ProgressBarBaseProps, DOMProps, AriaLabelingProps {}
|
|
45
|
+
|
|
46
|
+
export interface ProgressBarProps extends ProgressBarBaseProps {
|
|
47
|
+
/**
|
|
48
|
+
* Whether presentation is indeterminate when progress isn't known.
|
|
49
|
+
*/
|
|
50
|
+
isIndeterminate?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface AriaProgressBarProps extends ProgressBarProps, DOMProps, AriaLabelingProps {}
|
|
54
|
+
|
|
55
|
+
export interface ProgressBarAria {
|
|
56
|
+
/** Props for the progress bar container element. */
|
|
57
|
+
progressBarProps: DOMAttributes;
|
|
58
|
+
/** Props for the progress bar's visual label element (if any). */
|
|
59
|
+
labelProps: DOMAttributes;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function useProgressBar(props: AriaProgressBarProps): ProgressBarAria;
|
|
63
|
+
// Slot-threading form: sibling ported hooks pass their derived sub-slot as the trailing arg.
|
|
64
|
+
export function useProgressBar(
|
|
65
|
+
props: AriaProgressBarProps,
|
|
66
|
+
slot: symbol | undefined,
|
|
67
|
+
): ProgressBarAria;
|
|
68
|
+
export function useProgressBar(...args: any[]): ProgressBarAria {
|
|
69
|
+
const [user, slotArg] = splitSlot(args);
|
|
70
|
+
const slot = slotArg ?? S('useProgressBar');
|
|
71
|
+
const props = user[0] as AriaProgressBarProps;
|
|
72
|
+
|
|
73
|
+
let {
|
|
74
|
+
value = 0,
|
|
75
|
+
minValue = 0,
|
|
76
|
+
maxValue = 100,
|
|
77
|
+
valueLabel,
|
|
78
|
+
isIndeterminate,
|
|
79
|
+
formatOptions = {
|
|
80
|
+
style: 'percent',
|
|
81
|
+
},
|
|
82
|
+
} = props;
|
|
83
|
+
|
|
84
|
+
let domProps = filterDOMProps(props, { labelable: true });
|
|
85
|
+
let { labelProps, fieldProps } = useLabel(
|
|
86
|
+
{
|
|
87
|
+
...props,
|
|
88
|
+
// Progress bar is not an HTML input element so it
|
|
89
|
+
// shouldn't be labeled by a <label> element.
|
|
90
|
+
labelElementType: 'span',
|
|
91
|
+
},
|
|
92
|
+
subSlot(slot, 'label'),
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
value = clamp(value, minValue, maxValue);
|
|
96
|
+
let percentage = (value - minValue) / (maxValue - minValue);
|
|
97
|
+
let formatter = useNumberFormatter(formatOptions, subSlot(slot, 'formatter'));
|
|
98
|
+
|
|
99
|
+
if (!isIndeterminate && !valueLabel) {
|
|
100
|
+
let valueToFormat = formatOptions.style === 'percent' ? percentage : value;
|
|
101
|
+
valueLabel = formatter.format(valueToFormat);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
progressBarProps: mergeProps(domProps, {
|
|
106
|
+
...fieldProps,
|
|
107
|
+
'aria-valuenow': isIndeterminate ? undefined : value,
|
|
108
|
+
'aria-valuemin': minValue,
|
|
109
|
+
'aria-valuemax': maxValue,
|
|
110
|
+
'aria-valuetext': isIndeterminate ? undefined : (valueLabel as string),
|
|
111
|
+
role: 'progressbar',
|
|
112
|
+
}),
|
|
113
|
+
labelProps,
|
|
114
|
+
};
|
|
115
|
+
}
|