@redsift/design-system 11.5.0 → 11.6.0-muiv5-alpha.1
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/_virtual/_rollupPluginBabelHelpers.js +133 -0
- package/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/_virtual/jsx-runtime.js +4 -0
- package/_virtual/jsx-runtime.js.map +1 -0
- package/_virtual/react-jsx-runtime.development.js +4 -0
- package/_virtual/react-jsx-runtime.development.js.map +1 -0
- package/_virtual/react-jsx-runtime.production.min.js +4 -0
- package/_virtual/react-jsx-runtime.production.min.js.map +1 -0
- package/components/alert/Alert.d.ts +9 -0
- package/components/alert/Alert.js +117 -0
- package/components/alert/Alert.js.map +1 -0
- package/components/alert/intl/en-US.json.js +7 -0
- package/components/alert/intl/en-US.json.js.map +1 -0
- package/components/alert/intl/fr-FR.json.js +7 -0
- package/components/alert/intl/fr-FR.json.js.map +1 -0
- package/components/alert/intl/index.js +10 -0
- package/components/alert/intl/index.js.map +1 -0
- package/components/alert/styles.js +54 -0
- package/components/alert/styles.js.map +1 -0
- package/components/alert/types.d.ts +49 -0
- package/components/alert/types.js +20 -0
- package/components/alert/types.js.map +1 -0
- package/components/app-bar/AppBar.d.ts +9 -0
- package/components/app-bar/AppBar.js +95 -0
- package/components/app-bar/AppBar.js.map +1 -0
- package/components/app-bar/intl/en-US.json.js +9 -0
- package/components/app-bar/intl/en-US.json.js.map +1 -0
- package/components/app-bar/intl/fr-FR.json.js +9 -0
- package/components/app-bar/intl/fr-FR.json.js.map +1 -0
- package/components/app-bar/intl/index.js +10 -0
- package/components/app-bar/intl/index.js.map +1 -0
- package/components/app-bar/styles.js +139 -0
- package/components/app-bar/styles.js.map +1 -0
- package/components/app-bar/types.d.ts +31 -0
- package/components/app-container/AppContainer.d.ts +11 -0
- package/components/app-container/AppContainer.js +117 -0
- package/components/app-container/AppContainer.js.map +1 -0
- package/components/app-container/context.d.ts +6 -0
- package/components/app-container/context.js +6 -0
- package/components/app-container/context.js.map +1 -0
- package/components/app-container/styles.js +30 -0
- package/components/app-container/styles.js.map +1 -0
- package/components/app-container/types.d.ts +51 -0
- package/components/app-content/AppContent.d.ts +9 -0
- package/components/app-content/AppContent.js +42 -0
- package/components/app-content/AppContent.js.map +1 -0
- package/components/app-content/styles.js +54 -0
- package/components/app-content/styles.js.map +1 -0
- package/components/app-content/types.d.ts +19 -0
- package/components/app-side-panel/AppSidePanel.d.ts +9 -0
- package/components/app-side-panel/AppSidePanel.js +86 -0
- package/components/app-side-panel/AppSidePanel.js.map +1 -0
- package/components/app-side-panel/intl/en-US.json.js +9 -0
- package/components/app-side-panel/intl/en-US.json.js.map +1 -0
- package/components/app-side-panel/intl/fr-FR.json.js +9 -0
- package/components/app-side-panel/intl/fr-FR.json.js.map +1 -0
- package/components/app-side-panel/intl/index.js +10 -0
- package/components/app-side-panel/intl/index.js.map +1 -0
- package/components/app-side-panel/styles.js +183 -0
- package/components/app-side-panel/styles.js.map +1 -0
- package/components/app-side-panel/types.d.ts +39 -0
- package/components/app-side-panel/types.js +15 -0
- package/components/app-side-panel/types.js.map +1 -0
- package/components/app-side-panel/useAppSidePanel.d.ts +6 -0
- package/components/app-side-panel/useAppSidePanel.js +23 -0
- package/components/app-side-panel/useAppSidePanel.js.map +1 -0
- package/components/badge/Badge.d.ts +9 -0
- package/components/badge/Badge.js +44 -0
- package/components/badge/Badge.js.map +1 -0
- package/components/badge/styles.js +93 -0
- package/components/badge/styles.js.map +1 -0
- package/components/badge/types.d.ts +37 -0
- package/components/badge/types.js +14 -0
- package/components/badge/types.js.map +1 -0
- package/components/breadcrumb-item/BreadcrumbItem.d.ts +9 -0
- package/components/breadcrumb-item/BreadcrumbItem.js +47 -0
- package/components/breadcrumb-item/BreadcrumbItem.js.map +1 -0
- package/components/breadcrumb-item/styles.js +48 -0
- package/components/breadcrumb-item/styles.js.map +1 -0
- package/components/breadcrumb-item/types.d.ts +23 -0
- package/components/breadcrumbs/Breadcrumbs.d.ts +13 -0
- package/components/breadcrumbs/Breadcrumbs.js +61 -0
- package/components/breadcrumbs/Breadcrumbs.js.map +1 -0
- package/components/breadcrumbs/styles.js +38 -0
- package/components/breadcrumbs/styles.js.map +1 -0
- package/components/breadcrumbs/types.d.ts +19 -0
- package/components/button/Button.d.ts +13 -0
- package/components/button/Button.js +92 -0
- package/components/button/Button.js.map +1 -0
- package/components/button/styles.d.ts +20 -0
- package/components/button/styles.js +219 -0
- package/components/button/styles.js.map +1 -0
- package/components/button/types.d.ts +67 -0
- package/components/button/types.js +19 -0
- package/components/button/types.js.map +1 -0
- package/components/button-group/ButtonGroup.d.ts +9 -0
- package/components/button-group/ButtonGroup.js +67 -0
- package/components/button-group/ButtonGroup.js.map +1 -0
- package/components/button-group/styles.js +103 -0
- package/components/button-group/styles.js.map +1 -0
- package/components/button-group/types.d.ts +36 -0
- package/components/button-group/types.js +19 -0
- package/components/button-group/types.js.map +1 -0
- package/components/button-link/ButtonLink.d.ts +13 -0
- package/components/button-link/ButtonLink.js +85 -0
- package/components/button-link/ButtonLink.js.map +1 -0
- package/components/button-link/types.d.ts +18 -0
- package/components/card/Card.d.ts +13 -0
- package/components/card/Card.js +81 -0
- package/components/card/Card.js.map +1 -0
- package/components/card/intl/en-US.json.js +9 -0
- package/components/card/intl/en-US.json.js.map +1 -0
- package/components/card/intl/fr-FR.json.js +9 -0
- package/components/card/intl/fr-FR.json.js.map +1 -0
- package/components/card/intl/index.js +10 -0
- package/components/card/intl/index.js.map +1 -0
- package/components/card/styles.js +63 -0
- package/components/card/styles.js.map +1 -0
- package/components/card/types.d.ts +25 -0
- package/components/card-actions/CardActions.d.ts +9 -0
- package/components/card-actions/CardActions.js +33 -0
- package/components/card-actions/CardActions.js.map +1 -0
- package/components/card-actions/styles.js +15 -0
- package/components/card-actions/styles.js.map +1 -0
- package/components/card-actions/types.d.ts +11 -0
- package/components/card-body/CardBody.d.ts +9 -0
- package/components/card-body/CardBody.js +28 -0
- package/components/card-body/CardBody.js.map +1 -0
- package/components/card-body/styles.js +18 -0
- package/components/card-body/styles.js.map +1 -0
- package/components/card-body/types.d.ts +11 -0
- package/components/card-header/CardHeader.d.ts +9 -0
- package/components/card-header/CardHeader.js +56 -0
- package/components/card-header/CardHeader.js.map +1 -0
- package/components/card-header/styles.js +31 -0
- package/components/card-header/styles.js.map +1 -0
- package/components/card-header/types.d.ts +28 -0
- package/components/checkbox/Checkbox.d.ts +11 -0
- package/components/checkbox/Checkbox.js +135 -0
- package/components/checkbox/Checkbox.js.map +1 -0
- package/components/checkbox/styles.js +113 -0
- package/components/checkbox/styles.js.map +1 -0
- package/components/checkbox/types.d.ts +60 -0
- package/components/checkbox-group/CheckboxGroup.d.ts +10 -0
- package/components/checkbox-group/CheckboxGroup.js +101 -0
- package/components/checkbox-group/CheckboxGroup.js.map +1 -0
- package/components/checkbox-group/context.js +6 -0
- package/components/checkbox-group/context.js.map +1 -0
- package/components/checkbox-group/styles.js +78 -0
- package/components/checkbox-group/styles.js.map +1 -0
- package/components/checkbox-group/types.d.ts +72 -0
- package/components/checkbox-group/types.js +18 -0
- package/components/checkbox-group/types.js.map +1 -0
- package/components/conditional-wrapper/ConditionalWrapper.d.ts +6 -0
- package/components/conditional-wrapper/ConditionalWrapper.js +13 -0
- package/components/conditional-wrapper/ConditionalWrapper.js.map +1 -0
- package/components/conditional-wrapper/types.d.ts +10 -0
- package/components/detailed-card/DetailedCard.d.ts +15 -0
- package/components/detailed-card/DetailedCard.js +170 -0
- package/components/detailed-card/DetailedCard.js.map +1 -0
- package/components/detailed-card/intl/en-US.json.js +7 -0
- package/components/detailed-card/intl/en-US.json.js.map +1 -0
- package/components/detailed-card/intl/fr-FR.json.js +7 -0
- package/components/detailed-card/intl/fr-FR.json.js.map +1 -0
- package/components/detailed-card/intl/index.js +10 -0
- package/components/detailed-card/intl/index.js.map +1 -0
- package/components/detailed-card/styles.js +49 -0
- package/components/detailed-card/styles.js.map +1 -0
- package/components/detailed-card/types.d.ts +40 -0
- package/components/detailed-card-collapsible-section-items/DetailedCardCollapsibleSectionItems.d.ts +9 -0
- package/components/detailed-card-collapsible-section-items/DetailedCardCollapsibleSectionItems.js +33 -0
- package/components/detailed-card-collapsible-section-items/DetailedCardCollapsibleSectionItems.js.map +1 -0
- package/components/detailed-card-collapsible-section-items/styles.js +35 -0
- package/components/detailed-card-collapsible-section-items/styles.js.map +1 -0
- package/components/detailed-card-collapsible-section-items/types.d.ts +16 -0
- package/components/detailed-card-header/DetailedCardHeader.d.ts +9 -0
- package/components/detailed-card-header/DetailedCardHeader.js +45 -0
- package/components/detailed-card-header/DetailedCardHeader.js.map +1 -0
- package/components/detailed-card-header/styles.js +26 -0
- package/components/detailed-card-header/styles.js.map +1 -0
- package/components/detailed-card-header/types.d.ts +20 -0
- package/components/detailed-card-section/DetailedCardSection.d.ts +9 -0
- package/components/detailed-card-section/DetailedCardSection.js +90 -0
- package/components/detailed-card-section/DetailedCardSection.js.map +1 -0
- package/components/detailed-card-section/intl/en-US.json.js +9 -0
- package/components/detailed-card-section/intl/en-US.json.js.map +1 -0
- package/components/detailed-card-section/intl/fr-FR.json.js +9 -0
- package/components/detailed-card-section/intl/fr-FR.json.js.map +1 -0
- package/components/detailed-card-section/intl/index.js +10 -0
- package/components/detailed-card-section/intl/index.js.map +1 -0
- package/components/detailed-card-section/styles.js +69 -0
- package/components/detailed-card-section/styles.js.map +1 -0
- package/components/detailed-card-section/types.d.ts +27 -0
- package/components/detailed-card-section-item/DetailedCardSectionItem.d.ts +9 -0
- package/components/detailed-card-section-item/DetailedCardSectionItem.js +64 -0
- package/components/detailed-card-section-item/DetailedCardSectionItem.js.map +1 -0
- package/components/detailed-card-section-item/styles.js +34 -0
- package/components/detailed-card-section-item/styles.js.map +1 -0
- package/components/detailed-card-section-item/types.d.ts +35 -0
- package/components/flexbox/Flexbox.d.ts +9 -0
- package/components/flexbox/Flexbox.js +44 -0
- package/components/flexbox/Flexbox.js.map +1 -0
- package/components/flexbox/styles.js +54 -0
- package/components/flexbox/styles.js.map +1 -0
- package/components/flexbox/types.d.ts +24 -0
- package/components/focus-within-group/FocusWithinGroup.d.ts +41 -0
- package/components/focus-within-group/FocusWithinGroup.js +91 -0
- package/components/focus-within-group/FocusWithinGroup.js.map +1 -0
- package/components/focus-within-group/context.d.ts +7 -0
- package/components/focus-within-group/context.js +21 -0
- package/components/focus-within-group/context.js.map +1 -0
- package/components/focus-within-group/reducer.d.ts +5 -0
- package/components/focus-within-group/reducer.js +419 -0
- package/components/focus-within-group/reducer.js.map +1 -0
- package/components/focus-within-group/types.d.ts +143 -0
- package/components/focus-within-group/types.js +42 -0
- package/components/focus-within-group/types.js.map +1 -0
- package/components/focus-within-group/useFocusOnList.d.ts +5 -0
- package/components/focus-within-group/useFocusOnList.js +44 -0
- package/components/focus-within-group/useFocusOnList.js.map +1 -0
- package/components/focus-within-group/useFocusOnListItem.d.ts +39 -0
- package/components/focus-within-group/useFocusOnListItem.js +148 -0
- package/components/focus-within-group/useFocusOnListItem.js.map +1 -0
- package/components/gradient-border/index.d.ts +14 -0
- package/components/gradient-border/index.js +38 -0
- package/components/gradient-border/index.js.map +1 -0
- package/components/grid/Grid.d.ts +13 -0
- package/components/grid/Grid.js +45 -0
- package/components/grid/Grid.js.map +1 -0
- package/components/grid/styles.js +55 -0
- package/components/grid/styles.js.map +1 -0
- package/components/grid/types.d.ts +22 -0
- package/components/grid-item/GridItem.d.ts +9 -0
- package/components/grid-item/GridItem.js +28 -0
- package/components/grid-item/GridItem.js.map +1 -0
- package/components/grid-item/styles.js +16 -0
- package/components/grid-item/styles.js.map +1 -0
- package/components/grid-item/types.d.ts +11 -0
- package/components/heading/Heading.d.ts +9 -0
- package/components/heading/Heading.js +50 -0
- package/components/heading/Heading.js.map +1 -0
- package/components/heading/styles.js +67 -0
- package/components/heading/styles.js.map +1 -0
- package/components/heading/types.d.ts +62 -0
- package/components/heading/types.js +26 -0
- package/components/heading/types.js.map +1 -0
- package/components/icon/Icon.d.ts +10 -0
- package/components/icon/Icon.js +116 -0
- package/components/icon/Icon.js.map +1 -0
- package/components/icon/styles.js +84 -0
- package/components/icon/styles.js.map +1 -0
- package/components/icon/types.d.ts +57 -0
- package/components/icon/types.js +18 -0
- package/components/icon/types.js.map +1 -0
- package/components/icon-button/IconButton.d.ts +12 -0
- package/components/icon-button/IconButton.js +81 -0
- package/components/icon-button/IconButton.js.map +1 -0
- package/components/icon-button/styles.js +31 -0
- package/components/icon-button/styles.js.map +1 -0
- package/components/icon-button/types.d.ts +56 -0
- package/components/icon-button/types.js +19 -0
- package/components/icon-button/types.js.map +1 -0
- package/components/icon-button-link/IconButtonLink.d.ts +13 -0
- package/components/icon-button-link/IconButtonLink.js +76 -0
- package/components/icon-button-link/IconButtonLink.js.map +1 -0
- package/components/icon-button-link/types.d.ts +18 -0
- package/components/item/Item.d.ts +10 -0
- package/components/item/Item.js +225 -0
- package/components/item/Item.js.map +1 -0
- package/components/item/styles.d.ts +20 -0
- package/components/item/styles.js +129 -0
- package/components/item/styles.js.map +1 -0
- package/components/item/types.d.ts +59 -0
- package/components/item/useMenuItem.js +55 -0
- package/components/item/useMenuItem.js.map +1 -0
- package/components/link/Link.d.ts +14 -0
- package/components/link/Link.js +67 -0
- package/components/link/Link.js.map +1 -0
- package/components/link/styles.d.ts +15 -0
- package/components/link/styles.js +145 -0
- package/components/link/styles.js.map +1 -0
- package/components/link/types.d.ts +40 -0
- package/components/link-button/LinkButton.d.ts +13 -0
- package/components/link-button/LinkButton.js +66 -0
- package/components/link-button/LinkButton.js.map +1 -0
- package/components/link-button/types.d.ts +13 -0
- package/components/listbox/ActiveDescendantListbox.d.ts +8 -0
- package/components/listbox/ActiveDescendantListbox.js +74 -0
- package/components/listbox/ActiveDescendantListbox.js.map +1 -0
- package/components/listbox/Listbox.d.ts +10 -0
- package/components/listbox/Listbox.js +110 -0
- package/components/listbox/Listbox.js.map +1 -0
- package/components/listbox/RovingTabindexListbox.d.ts +8 -0
- package/components/listbox/RovingTabindexListbox.js +30 -0
- package/components/listbox/RovingTabindexListbox.js.map +1 -0
- package/components/listbox/context.d.ts +7 -0
- package/components/listbox/context.js +15 -0
- package/components/listbox/context.js.map +1 -0
- package/components/listbox/reducer.d.ts +5 -0
- package/components/listbox/reducer.js +45 -0
- package/components/listbox/reducer.js.map +1 -0
- package/components/listbox/styles.js +44 -0
- package/components/listbox/styles.js.map +1 -0
- package/components/listbox/types.d.ts +101 -0
- package/components/listbox/types.js +32 -0
- package/components/listbox/types.js.map +1 -0
- package/components/listbox/useListboxItem.d.ts +12 -0
- package/components/listbox/useListboxItem.js +90 -0
- package/components/listbox/useListboxItem.js.map +1 -0
- package/components/number/Number.d.ts +9 -0
- package/components/number/Number.js +105 -0
- package/components/number/Number.js.map +1 -0
- package/components/number/styles.js +10 -0
- package/components/number/styles.js.map +1 -0
- package/components/number/types.d.ts +63 -0
- package/components/number-field/NumberField.d.ts +10 -0
- package/components/number-field/NumberField.js +216 -0
- package/components/number-field/NumberField.js.map +1 -0
- package/components/number-field/styles.js +240 -0
- package/components/number-field/styles.js.map +1 -0
- package/components/number-field/types.d.ts +74 -0
- package/components/number-field/types.js +14 -0
- package/components/number-field/types.js.map +1 -0
- package/components/pill/Pill.d.ts +9 -0
- package/components/pill/Pill.js +93 -0
- package/components/pill/Pill.js.map +1 -0
- package/components/pill/styles.js +305 -0
- package/components/pill/styles.js.map +1 -0
- package/components/pill/types.d.ts +47 -0
- package/components/pill/types.js +15 -0
- package/components/pill/types.js.map +1 -0
- package/components/progress-bar/ProgressBar.d.ts +9 -0
- package/components/progress-bar/ProgressBar.js +35 -0
- package/components/progress-bar/ProgressBar.js.map +1 -0
- package/components/progress-bar/styles.js +38 -0
- package/components/progress-bar/styles.js.map +1 -0
- package/components/progress-bar/types.d.ts +20 -0
- package/components/radio/Radio.d.ts +11 -0
- package/components/radio/Radio.js +128 -0
- package/components/radio/Radio.js.map +1 -0
- package/components/radio/styles.js +113 -0
- package/components/radio/styles.js.map +1 -0
- package/components/radio/types.d.ts +58 -0
- package/components/radio-group/RadioGroup.d.ts +10 -0
- package/components/radio-group/RadioGroup.js +89 -0
- package/components/radio-group/RadioGroup.js.map +1 -0
- package/components/radio-group/context.js +6 -0
- package/components/radio-group/context.js.map +1 -0
- package/components/radio-group/styles.js +78 -0
- package/components/radio-group/styles.js.map +1 -0
- package/components/radio-group/types.d.ts +68 -0
- package/components/radio-group/types.js +18 -0
- package/components/radio-group/types.js.map +1 -0
- package/components/shared/styles.d.ts +17 -0
- package/components/shared/styles.js +250 -0
- package/components/shared/styles.js.map +1 -0
- package/components/shield/Shield.d.ts +9 -0
- package/components/shield/Shield.js +136 -0
- package/components/shield/Shield.js.map +1 -0
- package/components/shield/styles.js +71 -0
- package/components/shield/styles.js.map +1 -0
- package/components/shield/types.d.ts +52 -0
- package/components/shield/types.js +25 -0
- package/components/shield/types.js.map +1 -0
- package/components/side-navigation-menu/SideNavigationMenu.d.ts +9 -0
- package/components/side-navigation-menu/SideNavigationMenu.js +367 -0
- package/components/side-navigation-menu/SideNavigationMenu.js.map +1 -0
- package/components/side-navigation-menu/context.js +6 -0
- package/components/side-navigation-menu/context.js.map +1 -0
- package/components/side-navigation-menu/reducer.js +26 -0
- package/components/side-navigation-menu/reducer.js.map +1 -0
- package/components/side-navigation-menu/styles.js +196 -0
- package/components/side-navigation-menu/styles.js.map +1 -0
- package/components/side-navigation-menu/types.d.ts +72 -0
- package/components/side-navigation-menu/types.js +21 -0
- package/components/side-navigation-menu/types.js.map +1 -0
- package/components/side-navigation-menu-bar/SideNavigationMenuBar.d.ts +9 -0
- package/components/side-navigation-menu-bar/SideNavigationMenuBar.js +217 -0
- package/components/side-navigation-menu-bar/SideNavigationMenuBar.js.map +1 -0
- package/components/side-navigation-menu-bar/context.js +6 -0
- package/components/side-navigation-menu-bar/context.js.map +1 -0
- package/components/side-navigation-menu-bar/styles.js +89 -0
- package/components/side-navigation-menu-bar/styles.js.map +1 -0
- package/components/side-navigation-menu-bar/types.d.ts +65 -0
- package/components/side-navigation-menu-bar/types.js +22 -0
- package/components/side-navigation-menu-bar/types.js.map +1 -0
- package/components/side-navigation-menu-bar/useSideNavigationMenuBar.d.ts +9 -0
- package/components/side-navigation-menu-bar/useSideNavigationMenuBar.js +70 -0
- package/components/side-navigation-menu-bar/useSideNavigationMenuBar.js.map +1 -0
- package/components/side-navigation-menu-item/SideNavigationMenuItem.d.ts +9 -0
- package/components/side-navigation-menu-item/SideNavigationMenuItem.js +115 -0
- package/components/side-navigation-menu-item/SideNavigationMenuItem.js.map +1 -0
- package/components/side-navigation-menu-item/styles.js +174 -0
- package/components/side-navigation-menu-item/styles.js.map +1 -0
- package/components/side-navigation-menu-item/types.d.ts +51 -0
- package/components/skeleton/Skeleton.d.ts +15 -0
- package/components/skeleton/Skeleton.js +42 -0
- package/components/skeleton/Skeleton.js.map +1 -0
- package/components/skeleton/styles.js +84 -0
- package/components/skeleton/styles.js.map +1 -0
- package/components/skeleton/types.d.ts +18 -0
- package/components/skeleton-circle/SkeletonCircle.d.ts +9 -0
- package/components/skeleton-circle/SkeletonCircle.js +36 -0
- package/components/skeleton-circle/SkeletonCircle.js.map +1 -0
- package/components/skeleton-circle/styles.js +26 -0
- package/components/skeleton-circle/styles.js.map +1 -0
- package/components/skeleton-circle/types.d.ts +12 -0
- package/components/skeleton-text/SkeletonText.d.ts +9 -0
- package/components/skeleton-text/SkeletonText.js +42 -0
- package/components/skeleton-text/SkeletonText.js.map +1 -0
- package/components/skeleton-text/styles.js +39 -0
- package/components/skeleton-text/styles.js.map +1 -0
- package/components/skeleton-text/types.d.ts +36 -0
- package/components/skeleton-text/types.js +20 -0
- package/components/skeleton-text/types.js.map +1 -0
- package/components/spinner/Spinner.d.ts +9 -0
- package/components/spinner/Spinner.js +82 -0
- package/components/spinner/Spinner.js.map +1 -0
- package/components/spinner/images/spinner-grey-l1.svg.js +4 -0
- package/components/spinner/images/spinner-grey-l1.svg.js.map +1 -0
- package/components/spinner/images/spinner-grey-l2.svg.js +4 -0
- package/components/spinner/images/spinner-grey-l2.svg.js.map +1 -0
- package/components/spinner/images/spinner-grey-l3.svg.js +4 -0
- package/components/spinner/images/spinner-grey-l3.svg.js.map +1 -0
- package/components/spinner/images/spinner-primary-n.svg.js +4 -0
- package/components/spinner/images/spinner-primary-n.svg.js.map +1 -0
- package/components/spinner/intl/en-US.json.js +7 -0
- package/components/spinner/intl/en-US.json.js.map +1 -0
- package/components/spinner/intl/fr-FR.json.js +7 -0
- package/components/spinner/intl/fr-FR.json.js.map +1 -0
- package/components/spinner/intl/index.js +10 -0
- package/components/spinner/intl/index.js.map +1 -0
- package/components/spinner/styles.js +13 -0
- package/components/spinner/styles.js.map +1 -0
- package/components/spinner/types.d.ts +38 -0
- package/components/spinner/types.js +16 -0
- package/components/spinner/types.js.map +1 -0
- package/components/switch/Switch.d.ts +11 -0
- package/components/switch/Switch.js +137 -0
- package/components/switch/Switch.js.map +1 -0
- package/components/switch/styles.js +187 -0
- package/components/switch/styles.js.map +1 -0
- package/components/switch/types.d.ts +58 -0
- package/components/switch-group/SwitchGroup.d.ts +10 -0
- package/components/switch-group/SwitchGroup.js +101 -0
- package/components/switch-group/SwitchGroup.js.map +1 -0
- package/components/switch-group/context.js +6 -0
- package/components/switch-group/context.js.map +1 -0
- package/components/switch-group/styles.js +78 -0
- package/components/switch-group/styles.js.map +1 -0
- package/components/switch-group/types.d.ts +72 -0
- package/components/switch-group/types.js +18 -0
- package/components/switch-group/types.js.map +1 -0
- package/components/text/Text.d.ts +9 -0
- package/components/text/Text.js +51 -0
- package/components/text/Text.js.map +1 -0
- package/components/text/styles.js +112 -0
- package/components/text/styles.js.map +1 -0
- package/components/text/types.d.ts +73 -0
- package/components/text/types.js +34 -0
- package/components/text/types.js.map +1 -0
- package/components/text-area/TextArea.d.ts +10 -0
- package/components/text-area/TextArea.js +165 -0
- package/components/text-area/TextArea.js.map +1 -0
- package/components/text-area/styles.js +240 -0
- package/components/text-area/styles.js.map +1 -0
- package/components/text-area/types.d.ts +28 -0
- package/components/text-area/types.js +14 -0
- package/components/text-area/types.js.map +1 -0
- package/components/text-field/TextField.d.ts +10 -0
- package/components/text-field/TextField.js +197 -0
- package/components/text-field/TextField.js.map +1 -0
- package/components/text-field/intl/en-US.json.js +8 -0
- package/components/text-field/intl/en-US.json.js.map +1 -0
- package/components/text-field/intl/fr-FR.json.js +8 -0
- package/components/text-field/intl/fr-FR.json.js.map +1 -0
- package/components/text-field/intl/index.js +10 -0
- package/components/text-field/intl/index.js.map +1 -0
- package/components/text-field/styles.d.ts +22 -0
- package/components/text-field/styles.js +252 -0
- package/components/text-field/styles.js.map +1 -0
- package/components/text-field/types.d.ts +99 -0
- package/components/text-field/types.js +18 -0
- package/components/text-field/types.js.map +1 -0
- package/components/theme/context.d.ts +11 -0
- package/components/theme/context.js +7 -0
- package/components/theme/context.js.map +1 -0
- package/components/theme/useTheme.d.ts +5 -0
- package/components/theme/useTheme.js +13 -0
- package/components/theme/useTheme.js.map +1 -0
- package/hooks/useBoundingRect.d.ts +8 -0
- package/hooks/useBoundingRect.js +17 -0
- package/hooks/useBoundingRect.js.map +1 -0
- package/hooks/useComputeNumberOfRows.d.ts +15 -0
- package/hooks/useComputeNumberOfRows.js +40 -0
- package/hooks/useComputeNumberOfRows.js.map +1 -0
- package/hooks/useIsLoaded.d.ts +5 -0
- package/hooks/useIsLoaded.js +14 -0
- package/hooks/useIsLoaded.js.map +1 -0
- package/hooks/useWindowSize.d.ts +8 -0
- package/hooks/useWindowSize.js +42 -0
- package/hooks/useWindowSize.js.map +1 -0
- package/index.d.ts +157 -4667
- package/index.js +121 -24514
- package/index.js.map +1 -1
- package/package.json +4 -3
- package/packages/popovers/src/components/tooltip/Tooltip.js +62 -0
- package/packages/popovers/src/components/tooltip/Tooltip.js.map +1 -0
- package/packages/popovers/src/components/tooltip/context.js +6 -0
- package/packages/popovers/src/components/tooltip/context.js.map +1 -0
- package/packages/popovers/src/components/tooltip/types.js +28 -0
- package/packages/popovers/src/components/tooltip/types.js.map +1 -0
- package/packages/popovers/src/components/tooltip/useTooltip.js +78 -0
- package/packages/popovers/src/components/tooltip/useTooltip.js.map +1 -0
- package/packages/popovers/src/components/tooltip/useTooltipContext.js +13 -0
- package/packages/popovers/src/components/tooltip/useTooltipContext.js.map +1 -0
- package/packages/popovers/src/components/tooltip-content/TooltipContent.js +80 -0
- package/packages/popovers/src/components/tooltip-content/TooltipContent.js.map +1 -0
- package/packages/popovers/src/components/tooltip-content/styles.js +128 -0
- package/packages/popovers/src/components/tooltip-content/styles.js.map +1 -0
- package/packages/popovers/src/components/tooltip-trigger/TooltipTrigger.js +47 -0
- package/packages/popovers/src/components/tooltip-trigger/TooltipTrigger.js.map +1 -0
- package/react-aria/internationalized/date/DateFormatter.d.ts +25 -0
- package/react-aria/internationalized/date/DateFormatter.js +187 -0
- package/react-aria/internationalized/date/DateFormatter.js.map +1 -0
- package/react-aria/internationalized/message/MessageDictionary.d.ts +7 -0
- package/react-aria/internationalized/message/MessageDictionary.js +82 -0
- package/react-aria/internationalized/message/MessageDictionary.js.map +1 -0
- package/react-aria/internationalized/message/MessageFormatter.js +38 -0
- package/react-aria/internationalized/message/MessageFormatter.js.map +1 -0
- package/react-aria/internationalized/number/NumberFormatter.d.ts +6 -0
- package/react-aria/internationalized/number/NumberFormatter.js +222 -0
- package/react-aria/internationalized/number/NumberFormatter.js.map +1 -0
- package/react-aria/internationalized/number/NumberParser.js +288 -0
- package/react-aria/internationalized/number/NumberParser.js.map +1 -0
- package/react-aria/internationalized/string/LocalizedStringDictionary.d.ts +21 -0
- package/react-aria/internationalized/string/LocalizedStringDictionary.js +118 -0
- package/react-aria/internationalized/string/LocalizedStringDictionary.js.map +1 -0
- package/react-aria/internationalized/string/LocalizedStringFormatter.d.ts +21 -0
- package/react-aria/internationalized/string/LocalizedStringFormatter.js +70 -0
- package/react-aria/internationalized/string/LocalizedStringFormatter.js.map +1 -0
- package/react-aria/react-aria/button/useButton.js +95 -0
- package/react-aria/react-aria/button/useButton.js.map +1 -0
- package/react-aria/react-aria/focus/focusSafely.js +33 -0
- package/react-aria/react-aria/focus/focusSafely.js.map +1 -0
- package/react-aria/react-aria/focus/useFocusRing.js +57 -0
- package/react-aria/react-aria/focus/useFocusRing.js.map +1 -0
- package/react-aria/react-aria/focus/useFocusable.js +47 -0
- package/react-aria/react-aria/focus/useFocusable.js.map +1 -0
- package/react-aria/react-aria/form/useFormValidation.js +112 -0
- package/react-aria/react-aria/form/useFormValidation.js.map +1 -0
- package/react-aria/react-aria/i18n/context.d.ts +19 -0
- package/react-aria/react-aria/i18n/context.js +41 -0
- package/react-aria/react-aria/i18n/context.js.map +1 -0
- package/react-aria/react-aria/i18n/useCollator.d.ts +8 -0
- package/react-aria/react-aria/i18n/useCollator.js +25 -0
- package/react-aria/react-aria/i18n/useCollator.js.map +1 -0
- package/react-aria/react-aria/i18n/useDateFormatter.d.ts +13 -0
- package/react-aria/react-aria/i18n/useDateFormatter.js +39 -0
- package/react-aria/react-aria/i18n/useDateFormatter.js.map +1 -0
- package/react-aria/react-aria/i18n/useDefaultLocale.d.ts +10 -0
- package/react-aria/react-aria/i18n/useDefaultLocale.js +67 -0
- package/react-aria/react-aria/i18n/useDefaultLocale.js.map +1 -0
- package/react-aria/react-aria/i18n/useFilter.d.ts +15 -0
- package/react-aria/react-aria/i18n/useFilter.js +58 -0
- package/react-aria/react-aria/i18n/useFilter.js.map +1 -0
- package/react-aria/react-aria/i18n/useListFormatter.d.ts +8 -0
- package/react-aria/react-aria/i18n/useListFormatter.js +20 -0
- package/react-aria/react-aria/i18n/useListFormatter.js.map +1 -0
- package/react-aria/react-aria/i18n/useLocalizedStringFormatter.d.ts +15 -0
- package/react-aria/react-aria/i18n/useLocalizedStringFormatter.js +38 -0
- package/react-aria/react-aria/i18n/useLocalizedStringFormatter.js.map +1 -0
- package/react-aria/react-aria/i18n/useMessageFormatter.d.ts +13 -0
- package/react-aria/react-aria/i18n/useMessageFormatter.js +32 -0
- package/react-aria/react-aria/i18n/useMessageFormatter.js.map +1 -0
- package/react-aria/react-aria/i18n/useNumberFormatter.d.ts +10 -0
- package/react-aria/react-aria/i18n/useNumberFormatter.js +21 -0
- package/react-aria/react-aria/i18n/useNumberFormatter.js.map +1 -0
- package/react-aria/react-aria/i18n/utils.js +49 -0
- package/react-aria/react-aria/i18n/utils.js.map +1 -0
- package/react-aria/react-aria/interactions/context.js +20 -0
- package/react-aria/react-aria/interactions/context.js.map +1 -0
- package/react-aria/react-aria/interactions/createEventHandler.js +48 -0
- package/react-aria/react-aria/interactions/createEventHandler.js.map +1 -0
- package/react-aria/react-aria/interactions/textSelection.js +85 -0
- package/react-aria/react-aria/interactions/textSelection.js.map +1 -0
- package/react-aria/react-aria/interactions/useFocus.js +53 -0
- package/react-aria/react-aria/interactions/useFocus.js.map +1 -0
- package/react-aria/react-aria/interactions/useFocusVisible.js +236 -0
- package/react-aria/react-aria/interactions/useFocusVisible.js.map +1 -0
- package/react-aria/react-aria/interactions/useFocusWithin.js +65 -0
- package/react-aria/react-aria/interactions/useFocusWithin.js.map +1 -0
- package/react-aria/react-aria/interactions/useKeyboard.js +27 -0
- package/react-aria/react-aria/interactions/useKeyboard.js.map +1 -0
- package/react-aria/react-aria/interactions/usePress.js +769 -0
- package/react-aria/react-aria/interactions/usePress.js.map +1 -0
- package/react-aria/react-aria/interactions/useScrollWheel.js +31 -0
- package/react-aria/react-aria/interactions/useScrollWheel.js.map +1 -0
- package/react-aria/react-aria/interactions/utils.js +116 -0
- package/react-aria/react-aria/interactions/utils.js.map +1 -0
- package/react-aria/react-aria/label/useField.js +42 -0
- package/react-aria/react-aria/label/useField.js.map +1 -0
- package/react-aria/react-aria/label/useLabel.js +42 -0
- package/react-aria/react-aria/label/useLabel.js.map +1 -0
- package/react-aria/react-aria/live-announcer/LiveAnnouncer.js +121 -0
- package/react-aria/react-aria/live-announcer/LiveAnnouncer.js.map +1 -0
- package/react-aria/react-aria/numberfield/intl/en-US.json.js +11 -0
- package/react-aria/react-aria/numberfield/intl/en-US.json.js.map +1 -0
- package/react-aria/react-aria/numberfield/intl/fr-FR.json.js +11 -0
- package/react-aria/react-aria/numberfield/intl/fr-FR.json.js.map +1 -0
- package/react-aria/react-aria/numberfield/intl/index.js +10 -0
- package/react-aria/react-aria/numberfield/intl/index.js.map +1 -0
- package/react-aria/react-aria/numberfield/useNumberField.js +294 -0
- package/react-aria/react-aria/numberfield/useNumberField.js.map +1 -0
- package/react-aria/react-aria/spinbutton/intl/en-US.json.js +7 -0
- package/react-aria/react-aria/spinbutton/intl/en-US.json.js.map +1 -0
- package/react-aria/react-aria/spinbutton/intl/fr-FR.json.js +7 -0
- package/react-aria/react-aria/spinbutton/intl/fr-FR.json.js.map +1 -0
- package/react-aria/react-aria/spinbutton/intl/index.js +10 -0
- package/react-aria/react-aria/spinbutton/intl/index.js.map +1 -0
- package/react-aria/react-aria/spinbutton/useSpinButton.js +168 -0
- package/react-aria/react-aria/spinbutton/useSpinButton.js.map +1 -0
- package/react-aria/react-aria/ssr/SSRProvider.d.ts +22 -0
- package/react-aria/react-aria/ssr/SSRProvider.js +157 -0
- package/react-aria/react-aria/ssr/SSRProvider.js.map +1 -0
- package/react-aria/react-aria/textfield/useFormattedTextField.js +142 -0
- package/react-aria/react-aria/textfield/useFormattedTextField.js.map +1 -0
- package/react-aria/react-aria/textfield/useTextField.js +156 -0
- package/react-aria/react-aria/textfield/useTextField.js.map +1 -0
- package/react-aria/react-aria/utils/chain.js +33 -0
- package/react-aria/react-aria/utils/chain.js.map +1 -0
- package/react-aria/react-aria/utils/domHelpers.js +14 -0
- package/react-aria/react-aria/utils/domHelpers.js.map +1 -0
- package/react-aria/react-aria/utils/filterDOMProps.js +45 -0
- package/react-aria/react-aria/utils/filterDOMProps.js.map +1 -0
- package/react-aria/react-aria/utils/focusWithoutScrolling.js +88 -0
- package/react-aria/react-aria/utils/focusWithoutScrolling.js.map +1 -0
- package/react-aria/react-aria/utils/isVirtualEvent.js +51 -0
- package/react-aria/react-aria/utils/isVirtualEvent.js.map +1 -0
- package/react-aria/react-aria/utils/mergeProps.js +48 -0
- package/react-aria/react-aria/utils/mergeProps.js.map +1 -0
- package/react-aria/react-aria/utils/openLink.js +55 -0
- package/react-aria/react-aria/utils/openLink.js.map +1 -0
- package/react-aria/react-aria/utils/platform.js +69 -0
- package/react-aria/react-aria/utils/platform.js.map +1 -0
- package/react-aria/react-aria/utils/runAfterTransition.js +100 -0
- package/react-aria/react-aria/utils/runAfterTransition.js.map +1 -0
- package/react-aria/react-aria/utils/useDeepMemo.js +16 -0
- package/react-aria/react-aria/utils/useDeepMemo.js.map +1 -0
- package/react-aria/react-aria/utils/useEffectEvent.js +31 -0
- package/react-aria/react-aria/utils/useEffectEvent.js.map +1 -0
- package/react-aria/react-aria/utils/useEvent.js +21 -0
- package/react-aria/react-aria/utils/useEvent.js.map +1 -0
- package/react-aria/react-aria/utils/useFormReset.js +23 -0
- package/react-aria/react-aria/utils/useFormReset.js.map +1 -0
- package/react-aria/react-aria/utils/useGlobalListeners.js +44 -0
- package/react-aria/react-aria/utils/useGlobalListeners.js.map +1 -0
- package/react-aria/react-aria/utils/useId.js +86 -0
- package/react-aria/react-aria/utils/useId.js.map +1 -0
- package/react-aria/react-aria/utils/useLabels.js +39 -0
- package/react-aria/react-aria/utils/useLabels.js.map +1 -0
- package/react-aria/react-aria/utils/useLayoutEffect.js +21 -0
- package/react-aria/react-aria/utils/useLayoutEffect.js.map +1 -0
- package/react-aria/react-aria/utils/useSyncRef.js +29 -0
- package/react-aria/react-aria/utils/useSyncRef.js.map +1 -0
- package/react-aria/react-aria/utils/useValueEffect.js +52 -0
- package/react-aria/react-aria/utils/useValueEffect.js.map +1 -0
- package/react-aria/react-stately/form/useFormValidationState.js +191 -0
- package/react-aria/react-stately/form/useFormValidationState.js.map +1 -0
- package/react-aria/react-stately/numberfield/useNumberFieldState.js +196 -0
- package/react-aria/react-stately/numberfield/useNumberFieldState.js.map +1 -0
- package/react-aria/react-stately/utils/number.js +56 -0
- package/react-aria/react-stately/utils/number.js.map +1 -0
- package/react-aria/react-stately/utils/useControlledState.js +68 -0
- package/react-aria/react-stately/utils/useControlledState.js.map +1 -0
- package/react-aria/react-types/shared/locale.d.ts +3 -0
- package/types/colors.d.ts +102 -0
- package/types/colors.js +64 -0
- package/types/colors.js.map +1 -0
- package/types/fonts.d.ts +12 -0
- package/types/fonts.js +10 -0
- package/types/fonts.js.map +1 -0
- package/types/helpers.d.ts +23 -0
- package/types/products.d.ts +40 -0
- package/types/products.js +38 -0
- package/types/products.js.map +1 -0
- package/types/styles.d.ts +283 -0
- package/types/styles.js +161 -0
- package/types/styles.js.map +1 -0
- package/utils/filterComponents.d.ts +12 -0
- package/utils/filterComponents.js +24 -0
- package/utils/filterComponents.js.map +1 -0
- package/utils/getTextWidth.d.ts +6 -0
- package/utils/getTextWidth.js +32 -0
- package/utils/getTextWidth.js.map +1 -0
- package/utils/isComponent.d.ts +12 -0
- package/utils/isComponent.js +15 -0
- package/utils/isComponent.js.map +1 -0
- package/utils/partitionComponents.d.ts +10 -0
- package/utils/partitionComponents.js +26 -0
- package/utils/partitionComponents.js.map +1 -0
- package/utils/redsift-design-tokens.d.ts +1389 -0
- package/utils/redsift-design-tokens.js +1391 -0
- package/utils/redsift-design-tokens.js.map +1 -0
- package/utils/useId.d.ts +6 -0
- package/utils/useId.js +42 -0
- package/utils/useId.js.map +1 -0
- package/utils/warnIfNoAccessibleLabelFound.d.ts +11 -0
- package/utils/warnIfNoAccessibleLabelFound.js +20 -0
- package/utils/warnIfNoAccessibleLabelFound.js.map +1 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { isRTL } from './utils.js';
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { useIsSSR } from '../ssr/SSRProvider.js';
|
|
4
|
+
|
|
5
|
+
/* eslint-disable prefer-const */
|
|
6
|
+
// Locale passed from server by PackageLocalizationProvider.
|
|
7
|
+
const localeSymbol = Symbol.for('react-aria.i18n.locale');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Gets the locale setting of the browser.
|
|
11
|
+
*/
|
|
12
|
+
function getDefaultLocale() {
|
|
13
|
+
let locale = typeof window !== 'undefined' && window[localeSymbol] ||
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
|
|
16
|
+
try {
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
Intl.DateTimeFormat.supportedLocalesOf([locale]);
|
|
19
|
+
} catch (_err) {
|
|
20
|
+
locale = 'en-US';
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
locale,
|
|
24
|
+
direction: isRTL(locale) ? 'rtl' : 'ltr'
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
let currentLocale = getDefaultLocale();
|
|
28
|
+
let listeners = new Set();
|
|
29
|
+
function updateLocale() {
|
|
30
|
+
currentLocale = getDefaultLocale();
|
|
31
|
+
for (let listener of listeners) {
|
|
32
|
+
listener(currentLocale);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns the current browser/system language, and updates when it changes.
|
|
38
|
+
*/
|
|
39
|
+
function useDefaultLocale() {
|
|
40
|
+
let isSSR = useIsSSR();
|
|
41
|
+
let [defaultLocale, setDefaultLocale] = useState(currentLocale);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (listeners.size === 0) {
|
|
44
|
+
window.addEventListener('languagechange', updateLocale);
|
|
45
|
+
}
|
|
46
|
+
listeners.add(setDefaultLocale);
|
|
47
|
+
return () => {
|
|
48
|
+
listeners.delete(setDefaultLocale);
|
|
49
|
+
if (listeners.size === 0) {
|
|
50
|
+
window.removeEventListener('languagechange', updateLocale);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
54
|
+
|
|
55
|
+
// We cannot determine the browser's language on the server, so default to
|
|
56
|
+
// en-US. This will be updated after hydration on the client to the correct value.
|
|
57
|
+
if (isSSR) {
|
|
58
|
+
return {
|
|
59
|
+
locale: 'en-US',
|
|
60
|
+
direction: 'ltr'
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return defaultLocale;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { getDefaultLocale, useDefaultLocale };
|
|
67
|
+
//# sourceMappingURL=useDefaultLocale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDefaultLocale.js","sources":["../../../../src/react-aria/react-aria/i18n/useDefaultLocale.ts"],"sourcesContent":["/* eslint-disable prefer-const */\n// @ts-nocheck\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { Direction } from '../../react-types/shared';\nimport { isRTL } from './utils';\nimport { useEffect, useState } from 'react';\nimport { useIsSSR } from '../ssr';\n\nexport interface Locale {\n /** The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. */\n locale: string;\n /** The writing direction for the locale. */\n direction: Direction;\n}\n\n// Locale passed from server by PackageLocalizationProvider.\nconst localeSymbol = Symbol.for('react-aria.i18n.locale');\n\n/**\n * Gets the locale setting of the browser.\n */\nexport function getDefaultLocale(): Locale {\n let locale =\n (typeof window !== 'undefined' && window[localeSymbol]) ||\n // @ts-ignore\n (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) ||\n 'en-US';\n\n try {\n // @ts-ignore\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch (_err) {\n locale = 'en-US';\n }\n return {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr',\n };\n}\n\nlet currentLocale = getDefaultLocale();\nlet listeners = new Set<(locale: Locale) => void>();\n\nfunction updateLocale() {\n currentLocale = getDefaultLocale();\n for (let listener of listeners) {\n listener(currentLocale);\n }\n}\n\n/**\n * Returns the current browser/system language, and updates when it changes.\n */\nexport function useDefaultLocale(): Locale {\n let isSSR = useIsSSR();\n let [defaultLocale, setDefaultLocale] = useState(currentLocale);\n\n useEffect(() => {\n if (listeners.size === 0) {\n window.addEventListener('languagechange', updateLocale);\n }\n\n listeners.add(setDefaultLocale);\n\n return () => {\n listeners.delete(setDefaultLocale);\n if (listeners.size === 0) {\n window.removeEventListener('languagechange', updateLocale);\n }\n };\n }, []);\n\n // We cannot determine the browser's language on the server, so default to\n // en-US. This will be updated after hydration on the client to the correct value.\n if (isSSR) {\n return {\n locale: 'en-US',\n direction: 'ltr',\n };\n }\n\n return defaultLocale;\n}\n"],"names":["localeSymbol","Symbol","for","getDefaultLocale","locale","window","navigator","language","userLanguage","Intl","DateTimeFormat","supportedLocalesOf","_err","direction","isRTL","currentLocale","listeners","Set","updateLocale","listener","useDefaultLocale","isSSR","useIsSSR","defaultLocale","setDefaultLocale","useState","useEffect","size","addEventListener","add","delete","removeEventListener"],"mappings":";;;;AAAA;AA0BA;AACA,MAAMA,YAAY,GAAGC,MAAM,CAACC,GAAG,CAAC,wBAAwB,CAAC,CAAA;;AAEzD;AACA;AACA;AACO,SAASC,gBAAgBA,GAAW;EACzC,IAAIC,MAAM,GACP,OAAOC,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACL,YAAY,CAAC;AACtD;AACC,EAAA,OAAOM,SAAS,KAAK,WAAW,KAAKA,SAAS,CAACC,QAAQ,IAAID,SAAS,CAACE,YAAY,CAAE,IACpF,OAAO,CAAA;EAET,IAAI;AACF;IACAC,IAAI,CAACC,cAAc,CAACC,kBAAkB,CAAC,CAACP,MAAM,CAAC,CAAC,CAAA;GACjD,CAAC,OAAOQ,IAAI,EAAE;AACbR,IAAAA,MAAM,GAAG,OAAO,CAAA;AAClB,GAAA;EACA,OAAO;IACLA,MAAM;AACNS,IAAAA,SAAS,EAAEC,KAAK,CAACV,MAAM,CAAC,GAAG,KAAK,GAAG,KAAA;GACpC,CAAA;AACH,CAAA;AAEA,IAAIW,aAAa,GAAGZ,gBAAgB,EAAE,CAAA;AACtC,IAAIa,SAAS,GAAG,IAAIC,GAAG,EAA4B,CAAA;AAEnD,SAASC,YAAYA,GAAG;EACtBH,aAAa,GAAGZ,gBAAgB,EAAE,CAAA;AAClC,EAAA,KAAK,IAAIgB,QAAQ,IAAIH,SAAS,EAAE;IAC9BG,QAAQ,CAACJ,aAAa,CAAC,CAAA;AACzB,GAAA;AACF,CAAA;;AAEA;AACA;AACA;AACO,SAASK,gBAAgBA,GAAW;AACzC,EAAA,IAAIC,KAAK,GAAGC,QAAQ,EAAE,CAAA;EACtB,IAAI,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGC,QAAQ,CAACV,aAAa,CAAC,CAAA;AAE/DW,EAAAA,SAAS,CAAC,MAAM;AACd,IAAA,IAAIV,SAAS,CAACW,IAAI,KAAK,CAAC,EAAE;AACxBtB,MAAAA,MAAM,CAACuB,gBAAgB,CAAC,gBAAgB,EAAEV,YAAY,CAAC,CAAA;AACzD,KAAA;AAEAF,IAAAA,SAAS,CAACa,GAAG,CAACL,gBAAgB,CAAC,CAAA;AAE/B,IAAA,OAAO,MAAM;AACXR,MAAAA,SAAS,CAACc,MAAM,CAACN,gBAAgB,CAAC,CAAA;AAClC,MAAA,IAAIR,SAAS,CAACW,IAAI,KAAK,CAAC,EAAE;AACxBtB,QAAAA,MAAM,CAAC0B,mBAAmB,CAAC,gBAAgB,EAAEb,YAAY,CAAC,CAAA;AAC5D,OAAA;KACD,CAAA;GACF,EAAE,EAAE,CAAC,CAAA;;AAEN;AACA;AACA,EAAA,IAAIG,KAAK,EAAE;IACT,OAAO;AACLjB,MAAAA,MAAM,EAAE,OAAO;AACfS,MAAAA,SAAS,EAAE,KAAA;KACZ,CAAA;AACH,GAAA;AAEA,EAAA,OAAOU,aAAa,CAAA;AACtB;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface Filter {
|
|
2
|
+
/** Returns whether a string starts with a given substring. */
|
|
3
|
+
startsWith(string: string, substring: string): boolean;
|
|
4
|
+
/** Returns whether a string ends with a given substring. */
|
|
5
|
+
endsWith(string: string, substring: string): boolean;
|
|
6
|
+
/** Returns whether a string contains a given substring. */
|
|
7
|
+
contains(string: string, substring: string): boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Provides localized string search functionality that is useful for filtering or matching items
|
|
11
|
+
* in a list. Options can be provided to adjust the sensitivity to case, diacritics, and other parameters.
|
|
12
|
+
*/
|
|
13
|
+
declare function useFilter(options?: Intl.CollatorOptions): Filter;
|
|
14
|
+
|
|
15
|
+
export { Filter, useFilter };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { objectSpread2 as _objectSpread2 } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
|
+
import { useCollator } from './useCollator.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Provides localized string search functionality that is useful for filtering or matching items
|
|
7
|
+
* in a list. Options can be provided to adjust the sensitivity to case, diacritics, and other parameters.
|
|
8
|
+
*/
|
|
9
|
+
function useFilter(options) {
|
|
10
|
+
let collator = useCollator(_objectSpread2({
|
|
11
|
+
usage: 'search'
|
|
12
|
+
}, options));
|
|
13
|
+
|
|
14
|
+
// TODO(later): these methods don't currently support the ignorePunctuation option.
|
|
15
|
+
let startsWith = useCallback((string, substring) => {
|
|
16
|
+
if (substring.length === 0) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Normalize both strings so we can slice safely
|
|
21
|
+
// TODO: take into account the ignorePunctuation option as well...
|
|
22
|
+
string = string.normalize('NFC');
|
|
23
|
+
substring = substring.normalize('NFC');
|
|
24
|
+
return collator.compare(string.slice(0, substring.length), substring) === 0;
|
|
25
|
+
}, [collator]);
|
|
26
|
+
let endsWith = useCallback((string, substring) => {
|
|
27
|
+
if (substring.length === 0) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
string = string.normalize('NFC');
|
|
31
|
+
substring = substring.normalize('NFC');
|
|
32
|
+
return collator.compare(string.slice(-substring.length), substring) === 0;
|
|
33
|
+
}, [collator]);
|
|
34
|
+
let contains = useCallback((string, substring) => {
|
|
35
|
+
if (substring.length === 0) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
string = string.normalize('NFC');
|
|
39
|
+
substring = substring.normalize('NFC');
|
|
40
|
+
let scan = 0;
|
|
41
|
+
let sliceLen = substring.length;
|
|
42
|
+
for (; scan + sliceLen <= string.length; scan++) {
|
|
43
|
+
let slice = string.slice(scan, scan + sliceLen);
|
|
44
|
+
if (collator.compare(substring, slice) === 0) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}, [collator]);
|
|
50
|
+
return useMemo(() => ({
|
|
51
|
+
startsWith,
|
|
52
|
+
endsWith,
|
|
53
|
+
contains
|
|
54
|
+
}), [startsWith, endsWith, contains]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { useFilter };
|
|
58
|
+
//# sourceMappingURL=useFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFilter.js","sources":["../../../../src/react-aria/react-aria/i18n/useFilter.ts"],"sourcesContent":["/* eslint-disable prefer-const */\n// @ts-nocheck\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { useCollator } from './useCollator';\n\nexport interface Filter {\n /** Returns whether a string starts with a given substring. */\n startsWith(string: string, substring: string): boolean;\n /** Returns whether a string ends with a given substring. */\n endsWith(string: string, substring: string): boolean;\n /** Returns whether a string contains a given substring. */\n contains(string: string, substring: string): boolean;\n}\n\n/**\n * Provides localized string search functionality that is useful for filtering or matching items\n * in a list. Options can be provided to adjust the sensitivity to case, diacritics, and other parameters.\n */\nexport function useFilter(options?: Intl.CollatorOptions): Filter {\n let collator = useCollator({\n usage: 'search',\n ...options,\n });\n\n // TODO(later): these methods don't currently support the ignorePunctuation option.\n let startsWith = useCallback(\n (string, substring) => {\n if (substring.length === 0) {\n return true;\n }\n\n // Normalize both strings so we can slice safely\n // TODO: take into account the ignorePunctuation option as well...\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n return collator.compare(string.slice(0, substring.length), substring) === 0;\n },\n [collator]\n );\n\n let endsWith = useCallback(\n (string, substring) => {\n if (substring.length === 0) {\n return true;\n }\n\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n return collator.compare(string.slice(-substring.length), substring) === 0;\n },\n [collator]\n );\n\n let contains = useCallback(\n (string, substring) => {\n if (substring.length === 0) {\n return true;\n }\n\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n\n let scan = 0;\n let sliceLen = substring.length;\n for (; scan + sliceLen <= string.length; scan++) {\n let slice = string.slice(scan, scan + sliceLen);\n if (collator.compare(substring, slice) === 0) {\n return true;\n }\n }\n\n return false;\n },\n [collator]\n );\n\n return useMemo(\n () => ({\n startsWith,\n endsWith,\n contains,\n }),\n [startsWith, endsWith, contains]\n );\n}\n"],"names":["useFilter","options","collator","useCollator","_objectSpread","usage","startsWith","useCallback","string","substring","length","normalize","compare","slice","endsWith","contains","scan","sliceLen","useMemo"],"mappings":";;;;AA0BA;AACA;AACA;AACA;AACO,SAASA,SAASA,CAACC,OAA8B,EAAU;AAChE,EAAA,IAAIC,QAAQ,GAAGC,WAAW,CAAAC,cAAA,CAAA;AACxBC,IAAAA,KAAK,EAAE,QAAA;GACJJ,EAAAA,OAAO,CACX,CAAC,CAAA;;AAEF;EACA,IAAIK,UAAU,GAAGC,WAAW,CAC1B,CAACC,MAAM,EAAEC,SAAS,KAAK;AACrB,IAAA,IAAIA,SAAS,CAACC,MAAM,KAAK,CAAC,EAAE;AAC1B,MAAA,OAAO,IAAI,CAAA;AACb,KAAA;;AAEA;AACA;AACAF,IAAAA,MAAM,GAAGA,MAAM,CAACG,SAAS,CAAC,KAAK,CAAC,CAAA;AAChCF,IAAAA,SAAS,GAAGA,SAAS,CAACE,SAAS,CAAC,KAAK,CAAC,CAAA;AACtC,IAAA,OAAOT,QAAQ,CAACU,OAAO,CAACJ,MAAM,CAACK,KAAK,CAAC,CAAC,EAAEJ,SAAS,CAACC,MAAM,CAAC,EAAED,SAAS,CAAC,KAAK,CAAC,CAAA;AAC7E,GAAC,EACD,CAACP,QAAQ,CACX,CAAC,CAAA;EAED,IAAIY,QAAQ,GAAGP,WAAW,CACxB,CAACC,MAAM,EAAEC,SAAS,KAAK;AACrB,IAAA,IAAIA,SAAS,CAACC,MAAM,KAAK,CAAC,EAAE;AAC1B,MAAA,OAAO,IAAI,CAAA;AACb,KAAA;AAEAF,IAAAA,MAAM,GAAGA,MAAM,CAACG,SAAS,CAAC,KAAK,CAAC,CAAA;AAChCF,IAAAA,SAAS,GAAGA,SAAS,CAACE,SAAS,CAAC,KAAK,CAAC,CAAA;AACtC,IAAA,OAAOT,QAAQ,CAACU,OAAO,CAACJ,MAAM,CAACK,KAAK,CAAC,CAACJ,SAAS,CAACC,MAAM,CAAC,EAAED,SAAS,CAAC,KAAK,CAAC,CAAA;AAC3E,GAAC,EACD,CAACP,QAAQ,CACX,CAAC,CAAA;EAED,IAAIa,QAAQ,GAAGR,WAAW,CACxB,CAACC,MAAM,EAAEC,SAAS,KAAK;AACrB,IAAA,IAAIA,SAAS,CAACC,MAAM,KAAK,CAAC,EAAE;AAC1B,MAAA,OAAO,IAAI,CAAA;AACb,KAAA;AAEAF,IAAAA,MAAM,GAAGA,MAAM,CAACG,SAAS,CAAC,KAAK,CAAC,CAAA;AAChCF,IAAAA,SAAS,GAAGA,SAAS,CAACE,SAAS,CAAC,KAAK,CAAC,CAAA;IAEtC,IAAIK,IAAI,GAAG,CAAC,CAAA;AACZ,IAAA,IAAIC,QAAQ,GAAGR,SAAS,CAACC,MAAM,CAAA;IAC/B,OAAOM,IAAI,GAAGC,QAAQ,IAAIT,MAAM,CAACE,MAAM,EAAEM,IAAI,EAAE,EAAE;MAC/C,IAAIH,KAAK,GAAGL,MAAM,CAACK,KAAK,CAACG,IAAI,EAAEA,IAAI,GAAGC,QAAQ,CAAC,CAAA;MAC/C,IAAIf,QAAQ,CAACU,OAAO,CAACH,SAAS,EAAEI,KAAK,CAAC,KAAK,CAAC,EAAE;AAC5C,QAAA,OAAO,IAAI,CAAA;AACb,OAAA;AACF,KAAA;AAEA,IAAA,OAAO,KAAK,CAAA;AACd,GAAC,EACD,CAACX,QAAQ,CACX,CAAC,CAAA;EAED,OAAOgB,OAAO,CACZ,OAAO;IACLZ,UAAU;IACVQ,QAAQ;AACRC,IAAAA,QAAAA;GACD,CAAC,EACF,CAACT,UAAU,EAAEQ,QAAQ,EAAEC,QAAQ,CACjC,CAAC,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides localized list formatting for the current locale. Automatically updates when the locale changes,
|
|
3
|
+
* and handles caching of the list formatter for performance.
|
|
4
|
+
* @param options - Formatting options.
|
|
5
|
+
*/
|
|
6
|
+
declare function useListFormatter(options?: Intl.ListFormatOptions): Intl.ListFormat;
|
|
7
|
+
|
|
8
|
+
export { useListFormatter };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useLocale } from './context.js';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable prefer-const */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Provides localized list formatting for the current locale. Automatically updates when the locale changes,
|
|
8
|
+
* and handles caching of the list formatter for performance.
|
|
9
|
+
* @param options - Formatting options.
|
|
10
|
+
*/
|
|
11
|
+
function useListFormatter() {
|
|
12
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
13
|
+
let {
|
|
14
|
+
locale
|
|
15
|
+
} = useLocale();
|
|
16
|
+
return useMemo(() => new Intl.ListFormat(locale, options), [locale, options]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { useListFormatter };
|
|
20
|
+
//# sourceMappingURL=useListFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useListFormatter.js","sources":["../../../../src/react-aria/react-aria/i18n/useListFormatter.tsx"],"sourcesContent":["/* eslint-disable prefer-const */\n// @ts-nocheck\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { useLocale } from './context';\nimport { useMemo } from 'react';\n\n/**\n * Provides localized list formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the list formatter for performance.\n * @param options - Formatting options.\n */\nexport function useListFormatter(options: Intl.ListFormatOptions = {}): Intl.ListFormat {\n let { locale } = useLocale();\n return useMemo(() => new Intl.ListFormat(locale, options), [locale, options]);\n}\n"],"names":["useListFormatter","options","arguments","length","undefined","locale","useLocale","useMemo","Intl","ListFormat"],"mappings":";;;AAAA;;AAiBA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAgBA,GAAwD;AAAA,EAAA,IAAvDC,OAA+B,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE,CAAA;EACnE,IAAI;AAAEG,IAAAA,MAAAA;GAAQ,GAAGC,SAAS,EAAE,CAAA;AAC5B,EAAA,OAAOC,OAAO,CAAC,MAAM,IAAIC,IAAI,CAACC,UAAU,CAACJ,MAAM,EAAEJ,OAAO,CAAC,EAAE,CAACI,MAAM,EAAEJ,OAAO,CAAC,CAAC,CAAA;AAC/E;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LocalizedString, LocalizedStringFormatter } from '../../internationalized/string/LocalizedStringFormatter.js';
|
|
2
|
+
import { LocalizedStrings, LocalizedStringDictionary } from '../../internationalized/string/LocalizedStringDictionary.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns a cached LocalizedStringDictionary for the given strings.
|
|
6
|
+
*/
|
|
7
|
+
declare function useLocalizedStringDictionary<K extends string = string, T extends LocalizedString = string>(strings: LocalizedStrings<K, T>, packageName?: string): LocalizedStringDictionary<K, T>;
|
|
8
|
+
/**
|
|
9
|
+
* Provides localized string formatting for the current locale. Supports interpolating variables,
|
|
10
|
+
* selecting the correct pluralization, and formatting numbers. Automatically updates when the locale changes.
|
|
11
|
+
* @param strings - A mapping of languages to localized strings by key.
|
|
12
|
+
*/
|
|
13
|
+
declare function useLocalizedStringFormatter<K extends string = string, T extends LocalizedString = string>(strings: LocalizedStrings<K, T>, packageName?: string): LocalizedStringFormatter<K, T>;
|
|
14
|
+
|
|
15
|
+
export { useLocalizedStringDictionary, useLocalizedStringFormatter };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useLocale } from './context.js';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { LocalizedStringDictionary } from '../../internationalized/string/LocalizedStringDictionary.js';
|
|
4
|
+
import { LocalizedStringFormatter } from '../../internationalized/string/LocalizedStringFormatter.js';
|
|
5
|
+
|
|
6
|
+
/* eslint-disable prefer-const */
|
|
7
|
+
const cache = new WeakMap();
|
|
8
|
+
function getCachedDictionary(strings) {
|
|
9
|
+
let dictionary = cache.get(strings);
|
|
10
|
+
if (!dictionary) {
|
|
11
|
+
dictionary = new LocalizedStringDictionary(strings);
|
|
12
|
+
cache.set(strings, dictionary);
|
|
13
|
+
}
|
|
14
|
+
return dictionary;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Returns a cached LocalizedStringDictionary for the given strings.
|
|
19
|
+
*/
|
|
20
|
+
function useLocalizedStringDictionary(strings, packageName) {
|
|
21
|
+
return packageName && LocalizedStringDictionary.getGlobalDictionaryForPackage(packageName) || getCachedDictionary(strings);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Provides localized string formatting for the current locale. Supports interpolating variables,
|
|
26
|
+
* selecting the correct pluralization, and formatting numbers. Automatically updates when the locale changes.
|
|
27
|
+
* @param strings - A mapping of languages to localized strings by key.
|
|
28
|
+
*/
|
|
29
|
+
function useLocalizedStringFormatter(strings, packageName) {
|
|
30
|
+
let {
|
|
31
|
+
locale
|
|
32
|
+
} = useLocale();
|
|
33
|
+
let dictionary = useLocalizedStringDictionary(strings, packageName);
|
|
34
|
+
return useMemo(() => new LocalizedStringFormatter(locale, dictionary), [locale, dictionary]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { useLocalizedStringDictionary, useLocalizedStringFormatter };
|
|
38
|
+
//# sourceMappingURL=useLocalizedStringFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocalizedStringFormatter.js","sources":["../../../../src/react-aria/react-aria/i18n/useLocalizedStringFormatter.ts"],"sourcesContent":["/* eslint-disable prefer-const */\n// @ts-nocheck\n/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n LocalizedString,\n LocalizedStringDictionary,\n LocalizedStringFormatter,\n LocalizedStrings,\n} from '../../internationalized/string';\nimport { useLocale } from './context';\nimport { useMemo } from 'react';\n\nconst cache = new WeakMap();\nfunction getCachedDictionary<K extends string, T extends LocalizedString>(\n strings: LocalizedStrings<K, T>\n): LocalizedStringDictionary<K, T> {\n let dictionary = cache.get(strings);\n if (!dictionary) {\n dictionary = new LocalizedStringDictionary(strings);\n cache.set(strings, dictionary);\n }\n\n return dictionary;\n}\n\n/**\n * Returns a cached LocalizedStringDictionary for the given strings.\n */\nexport function useLocalizedStringDictionary<K extends string = string, T extends LocalizedString = string>(\n strings: LocalizedStrings<K, T>,\n packageName?: string\n): LocalizedStringDictionary<K, T> {\n return (\n (packageName && LocalizedStringDictionary.getGlobalDictionaryForPackage(packageName)) ||\n getCachedDictionary(strings)\n );\n}\n\n/**\n * Provides localized string formatting for the current locale. Supports interpolating variables,\n * selecting the correct pluralization, and formatting numbers. Automatically updates when the locale changes.\n * @param strings - A mapping of languages to localized strings by key.\n */\nexport function useLocalizedStringFormatter<K extends string = string, T extends LocalizedString = string>(\n strings: LocalizedStrings<K, T>,\n packageName?: string\n): LocalizedStringFormatter<K, T> {\n let { locale } = useLocale();\n let dictionary = useLocalizedStringDictionary(strings, packageName);\n return useMemo(() => new LocalizedStringFormatter(locale, dictionary), [locale, dictionary]);\n}\n"],"names":["cache","WeakMap","getCachedDictionary","strings","dictionary","get","LocalizedStringDictionary","set","useLocalizedStringDictionary","packageName","getGlobalDictionaryForPackage","useLocalizedStringFormatter","locale","useLocale","useMemo","LocalizedStringFormatter"],"mappings":";;;;;AAAA;AAuBA,MAAMA,KAAK,GAAG,IAAIC,OAAO,EAAE,CAAA;AAC3B,SAASC,mBAAmBA,CAC1BC,OAA+B,EACE;AACjC,EAAA,IAAIC,UAAU,GAAGJ,KAAK,CAACK,GAAG,CAACF,OAAO,CAAC,CAAA;EACnC,IAAI,CAACC,UAAU,EAAE;AACfA,IAAAA,UAAU,GAAG,IAAIE,yBAAyB,CAACH,OAAO,CAAC,CAAA;AACnDH,IAAAA,KAAK,CAACO,GAAG,CAACJ,OAAO,EAAEC,UAAU,CAAC,CAAA;AAChC,GAAA;AAEA,EAAA,OAAOA,UAAU,CAAA;AACnB,CAAA;;AAEA;AACA;AACA;AACO,SAASI,4BAA4BA,CAC1CL,OAA+B,EAC/BM,WAAoB,EACa;AACjC,EAAA,OACGA,WAAW,IAAIH,yBAAyB,CAACI,6BAA6B,CAACD,WAAW,CAAC,IACpFP,mBAAmB,CAACC,OAAO,CAAC,CAAA;AAEhC,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASQ,2BAA2BA,CACzCR,OAA+B,EAC/BM,WAAoB,EACY;EAChC,IAAI;AAAEG,IAAAA,MAAAA;GAAQ,GAAGC,SAAS,EAAE,CAAA;AAC5B,EAAA,IAAIT,UAAU,GAAGI,4BAA4B,CAACL,OAAO,EAAEM,WAAW,CAAC,CAAA;AACnE,EAAA,OAAOK,OAAO,CAAC,MAAM,IAAIC,wBAAwB,CAACH,MAAM,EAAER,UAAU,CAAC,EAAE,CAACQ,MAAM,EAAER,UAAU,CAAC,CAAC,CAAA;AAC9F;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LocalizedStrings } from '../../internationalized/message/MessageDictionary.js';
|
|
2
|
+
|
|
3
|
+
type FormatMessage = (key: string, variables?: {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Handles formatting ICU Message strings to create localized strings for the current locale.
|
|
8
|
+
* Automatically updates when the locale changes, and handles caching of messages for performance.
|
|
9
|
+
* @param strings - A mapping of languages to strings by key.
|
|
10
|
+
*/
|
|
11
|
+
declare function useMessageFormatter(strings: LocalizedStrings): FormatMessage;
|
|
12
|
+
|
|
13
|
+
export { FormatMessage, useMessageFormatter };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useMemo, useCallback } from 'react';
|
|
2
|
+
import { useLocale } from './context.js';
|
|
3
|
+
import { MessageFormatter } from '../../internationalized/message/MessageFormatter.js';
|
|
4
|
+
import { MessageDictionary } from '../../internationalized/message/MessageDictionary.js';
|
|
5
|
+
|
|
6
|
+
/* eslint-disable prefer-const */
|
|
7
|
+
const cache = new WeakMap();
|
|
8
|
+
function getCachedDictionary(strings) {
|
|
9
|
+
let dictionary = cache.get(strings);
|
|
10
|
+
if (!dictionary) {
|
|
11
|
+
dictionary = new MessageDictionary(strings);
|
|
12
|
+
cache.set(strings, dictionary);
|
|
13
|
+
}
|
|
14
|
+
return dictionary;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Handles formatting ICU Message strings to create localized strings for the current locale.
|
|
19
|
+
* Automatically updates when the locale changes, and handles caching of messages for performance.
|
|
20
|
+
* @param strings - A mapping of languages to strings by key.
|
|
21
|
+
*/
|
|
22
|
+
function useMessageFormatter(strings) {
|
|
23
|
+
let {
|
|
24
|
+
locale
|
|
25
|
+
} = useLocale();
|
|
26
|
+
let dictionary = useMemo(() => getCachedDictionary(strings), [strings]);
|
|
27
|
+
let formatter = useMemo(() => new MessageFormatter(locale, dictionary), [locale, dictionary]);
|
|
28
|
+
return useCallback((key, variables) => formatter.format(key, variables), [formatter]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { useMessageFormatter };
|
|
32
|
+
//# sourceMappingURL=useMessageFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMessageFormatter.js","sources":["../../../../src/react-aria/react-aria/i18n/useMessageFormatter.ts"],"sourcesContent":["/* eslint-disable prefer-const */\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { LocalizedStrings, MessageDictionary, MessageFormatter } from '../../internationalized/message';\nimport { useCallback, useMemo } from 'react';\nimport { useLocale } from './context';\n\nexport type FormatMessage = (key: string, variables?: { [key: string]: any }) => string;\n\nconst cache = new WeakMap();\nfunction getCachedDictionary(strings: LocalizedStrings) {\n let dictionary = cache.get(strings);\n if (!dictionary) {\n dictionary = new MessageDictionary(strings);\n cache.set(strings, dictionary);\n }\n\n return dictionary;\n}\n\n/**\n * Handles formatting ICU Message strings to create localized strings for the current locale.\n * Automatically updates when the locale changes, and handles caching of messages for performance.\n * @param strings - A mapping of languages to strings by key.\n */\nexport function useMessageFormatter(strings: LocalizedStrings): FormatMessage {\n let { locale } = useLocale();\n let dictionary = useMemo(() => getCachedDictionary(strings), [strings]);\n let formatter = useMemo(() => new MessageFormatter(locale, dictionary), [locale, dictionary]);\n return useCallback((key, variables) => formatter.format(key, variables), [formatter]);\n}\n"],"names":["cache","WeakMap","getCachedDictionary","strings","dictionary","get","MessageDictionary","set","useMessageFormatter","locale","useLocale","useMemo","formatter","MessageFormatter","useCallback","key","variables","format"],"mappings":";;;;;AAAA;AAmBA,MAAMA,KAAK,GAAG,IAAIC,OAAO,EAAE,CAAA;AAC3B,SAASC,mBAAmBA,CAACC,OAAyB,EAAE;AACtD,EAAA,IAAIC,UAAU,GAAGJ,KAAK,CAACK,GAAG,CAACF,OAAO,CAAC,CAAA;EACnC,IAAI,CAACC,UAAU,EAAE;AACfA,IAAAA,UAAU,GAAG,IAAIE,iBAAiB,CAACH,OAAO,CAAC,CAAA;AAC3CH,IAAAA,KAAK,CAACO,GAAG,CAACJ,OAAO,EAAEC,UAAU,CAAC,CAAA;AAChC,GAAA;AAEA,EAAA,OAAOA,UAAU,CAAA;AACnB,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASI,mBAAmBA,CAACL,OAAyB,EAAiB;EAC5E,IAAI;AAAEM,IAAAA,MAAAA;GAAQ,GAAGC,SAAS,EAAE,CAAA;AAC5B,EAAA,IAAIN,UAAU,GAAGO,OAAO,CAAC,MAAMT,mBAAmB,CAACC,OAAO,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC,CAAA;AACvE,EAAA,IAAIS,SAAS,GAAGD,OAAO,CAAC,MAAM,IAAIE,gBAAgB,CAACJ,MAAM,EAAEL,UAAU,CAAC,EAAE,CAACK,MAAM,EAAEL,UAAU,CAAC,CAAC,CAAA;AAC7F,EAAA,OAAOU,WAAW,CAAC,CAACC,GAAG,EAAEC,SAAS,KAAKJ,SAAS,CAACK,MAAM,CAACF,GAAG,EAAEC,SAAS,CAAC,EAAE,CAACJ,SAAS,CAAC,CAAC,CAAA;AACvF;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NumberFormatOptions } from '../../internationalized/number/NumberFormatter.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Provides localized number formatting for the current locale. Automatically updates when the locale changes,
|
|
5
|
+
* and handles caching of the number formatter for performance.
|
|
6
|
+
* @param options - Formatting options.
|
|
7
|
+
*/
|
|
8
|
+
declare function useNumberFormatter(options?: NumberFormatOptions): Intl.NumberFormat;
|
|
9
|
+
|
|
10
|
+
export { useNumberFormatter };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useLocale } from './context.js';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { NumberFormatter } from '../../internationalized/number/NumberFormatter.js';
|
|
4
|
+
|
|
5
|
+
/* eslint-disable prefer-const */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Provides localized number formatting for the current locale. Automatically updates when the locale changes,
|
|
9
|
+
* and handles caching of the number formatter for performance.
|
|
10
|
+
* @param options - Formatting options.
|
|
11
|
+
*/
|
|
12
|
+
function useNumberFormatter() {
|
|
13
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
14
|
+
let {
|
|
15
|
+
locale
|
|
16
|
+
} = useLocale();
|
|
17
|
+
return useMemo(() => new NumberFormatter(locale, options), [locale, options]);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { useNumberFormatter };
|
|
21
|
+
//# sourceMappingURL=useNumberFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNumberFormatter.js","sources":["../../../../src/react-aria/react-aria/i18n/useNumberFormatter.ts"],"sourcesContent":["/* eslint-disable prefer-const */\n// @ts-nocheck\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { NumberFormatOptions, NumberFormatter } from '../../internationalized/number';\nimport { useLocale } from './context';\nimport { useMemo } from 'react';\n\n/**\n * Provides localized number formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the number formatter for performance.\n * @param options - Formatting options.\n */\nexport function useNumberFormatter(options: NumberFormatOptions = {}): Intl.NumberFormat {\n let { locale } = useLocale();\n return useMemo(() => new NumberFormatter(locale, options), [locale, options]);\n}\n"],"names":["useNumberFormatter","options","arguments","length","undefined","locale","useLocale","useMemo","NumberFormatter"],"mappings":";;;;AAAA;;AAkBA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAkBA,GAAuD;AAAA,EAAA,IAAtDC,OAA4B,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE,CAAA;EAClE,IAAI;AAAEG,IAAAA,MAAAA;GAAQ,GAAGC,SAAS,EAAE,CAAA;AAC5B,EAAA,OAAOC,OAAO,CAAC,MAAM,IAAIC,eAAe,CAACH,MAAM,EAAEJ,OAAO,CAAC,EAAE,CAACI,MAAM,EAAEJ,OAAO,CAAC,CAAC,CAAA;AAC/E;;;;"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* eslint-disable prefer-const */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// https://en.wikipedia.org/wiki/Right-to-left
|
|
16
|
+
const RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);
|
|
17
|
+
const RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Determines if a locale is read right to left using [Intl.Locale]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale}.
|
|
21
|
+
*/
|
|
22
|
+
function isRTL(localeString) {
|
|
23
|
+
// If the Intl.Locale API is available, use it to get the locale's text direction.
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
if (Intl.Locale) {
|
|
26
|
+
let locale = new Intl.Locale(localeString).maximize();
|
|
27
|
+
|
|
28
|
+
// Use the text info object to get the direction if possible.
|
|
29
|
+
// @ts-ignore - this was implemented as a property by some browsers before it was standardized as a function.
|
|
30
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
|
|
31
|
+
let textInfo = typeof locale.getTextInfo === 'function' ? locale.getTextInfo() : locale.textInfo;
|
|
32
|
+
if (textInfo) {
|
|
33
|
+
return textInfo.direction === 'rtl';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Fallback: guess using the script.
|
|
37
|
+
// This is more accurate than guessing by language, since languages can be written in multiple scripts.
|
|
38
|
+
if (locale.script) {
|
|
39
|
+
return RTL_SCRIPTS.has(locale.script);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// If not, just guess by the language (first part of the locale)
|
|
44
|
+
let lang = localeString.split('-')[0];
|
|
45
|
+
return RTL_LANGS.has(lang);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { isRTL };
|
|
49
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/react-aria/react-aria/i18n/utils.ts"],"sourcesContent":["/* eslint-disable prefer-const */\n// @ts-nocheck\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// https://en.wikipedia.org/wiki/Right-to-left\nconst RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);\nconst RTL_LANGS = new Set([\n 'ae',\n 'ar',\n 'arc',\n 'bcc',\n 'bqi',\n 'ckb',\n 'dv',\n 'fa',\n 'glk',\n 'he',\n 'ku',\n 'mzn',\n 'nqo',\n 'pnb',\n 'ps',\n 'sd',\n 'ug',\n 'ur',\n 'yi',\n]);\n\n/**\n * Determines if a locale is read right to left using [Intl.Locale]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale}.\n */\nexport function isRTL(localeString: string) {\n // If the Intl.Locale API is available, use it to get the locale's text direction.\n // @ts-ignore\n if (Intl.Locale) {\n let locale = new Intl.Locale(localeString).maximize();\n\n // Use the text info object to get the direction if possible.\n // @ts-ignore - this was implemented as a property by some browsers before it was standardized as a function.\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo\n let textInfo = typeof locale.getTextInfo === 'function' ? locale.getTextInfo() : locale.textInfo;\n if (textInfo) {\n return textInfo.direction === 'rtl';\n }\n\n // Fallback: guess using the script.\n // This is more accurate than guessing by language, since languages can be written in multiple scripts.\n if (locale.script) {\n return RTL_SCRIPTS.has(locale.script);\n }\n }\n\n // If not, just guess by the language (first part of the locale)\n let lang = localeString.split('-')[0];\n return RTL_LANGS.has(lang);\n}\n"],"names":["RTL_SCRIPTS","Set","RTL_LANGS","isRTL","localeString","Intl","Locale","locale","maximize","textInfo","getTextInfo","direction","script","has","lang","split"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,MAAMA,WAAW,GAAG,IAAIC,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;AAC7G,MAAMC,SAAS,GAAG,IAAID,GAAG,CAAC,CACxB,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,CACL,CAAC,CAAA;;AAEF;AACA;AACA;AACO,SAASE,KAAKA,CAACC,YAAoB,EAAE;AAC1C;AACA;EACA,IAAIC,IAAI,CAACC,MAAM,EAAE;AACf,IAAA,IAAIC,MAAM,GAAG,IAAIF,IAAI,CAACC,MAAM,CAACF,YAAY,CAAC,CAACI,QAAQ,EAAE,CAAA;;AAErD;AACA;AACA;AACA,IAAA,IAAIC,QAAQ,GAAG,OAAOF,MAAM,CAACG,WAAW,KAAK,UAAU,GAAGH,MAAM,CAACG,WAAW,EAAE,GAAGH,MAAM,CAACE,QAAQ,CAAA;AAChG,IAAA,IAAIA,QAAQ,EAAE;AACZ,MAAA,OAAOA,QAAQ,CAACE,SAAS,KAAK,KAAK,CAAA;AACrC,KAAA;;AAEA;AACA;IACA,IAAIJ,MAAM,CAACK,MAAM,EAAE;AACjB,MAAA,OAAOZ,WAAW,CAACa,GAAG,CAACN,MAAM,CAACK,MAAM,CAAC,CAAA;AACvC,KAAA;AACF,GAAA;;AAEA;EACA,IAAIE,IAAI,GAAGV,YAAY,CAACW,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;AACrC,EAAA,OAAOb,SAAS,CAACW,GAAG,CAACC,IAAI,CAAC,CAAA;AAC5B;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
const PressResponderContext = /*#__PURE__*/React__default.createContext({
|
|
15
|
+
register: () => {}
|
|
16
|
+
});
|
|
17
|
+
PressResponderContext.displayName = 'PressResponderContext';
|
|
18
|
+
|
|
19
|
+
export { PressResponderContext };
|
|
20
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../../../src/react-aria/react-aria/interactions/context.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { FocusableElement } from '../../react-types/shared';\nimport { PressProps } from './usePress';\nimport React, { MutableRefObject } from 'react';\n\ninterface IPressResponderContext extends PressProps {\n register(): void;\n ref?: MutableRefObject<FocusableElement>;\n}\n\nexport const PressResponderContext = React.createContext<IPressResponderContext>({ register: () => {} });\nPressResponderContext.displayName = 'PressResponderContext';\n"],"names":["PressResponderContext","React","createContext","register","displayName"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MAWaA,qBAAqB,gBAAGC,cAAK,CAACC,aAAa,CAAyB;EAAEC,QAAQ,EAAEA,MAAM,EAAC;AAAE,CAAC,EAAC;AACxGH,qBAAqB,CAACI,WAAW,GAAG,uBAAuB;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { objectSpread2 as _objectSpread2 } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable prefer-const */
|
|
4
|
+
// @ts-nocheck
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This function wraps a React event handler to make stopPropagation the default, and support continuePropagation instead.
|
|
19
|
+
*/
|
|
20
|
+
function createEventHandler(handler) {
|
|
21
|
+
if (!handler) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
let shouldStopPropagation = true;
|
|
25
|
+
return e => {
|
|
26
|
+
let event = _objectSpread2(_objectSpread2({}, e), {}, {
|
|
27
|
+
preventDefault() {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
},
|
|
30
|
+
isDefaultPrevented() {
|
|
31
|
+
return e.isDefaultPrevented();
|
|
32
|
+
},
|
|
33
|
+
stopPropagation() {
|
|
34
|
+
console.error('stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.');
|
|
35
|
+
},
|
|
36
|
+
continuePropagation() {
|
|
37
|
+
shouldStopPropagation = false;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
handler(event);
|
|
41
|
+
if (shouldStopPropagation) {
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { createEventHandler };
|
|
48
|
+
//# sourceMappingURL=createEventHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEventHandler.js","sources":["../../../../src/react-aria/react-aria/interactions/createEventHandler.ts"],"sourcesContent":["/* eslint-disable prefer-const */\n// @ts-nocheck\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { BaseEvent } from '../../react-types/shared';\nimport { SyntheticEvent } from 'react';\n\n/**\n * This function wraps a React event handler to make stopPropagation the default, and support continuePropagation instead.\n */\nexport function createEventHandler<T extends SyntheticEvent>(\n handler?: (e: BaseEvent<T>) => void\n): ((e: T) => void) | undefined {\n if (!handler) {\n return undefined;\n }\n\n let shouldStopPropagation = true;\n return (e: T) => {\n let event: BaseEvent<T> = {\n ...e,\n preventDefault() {\n e.preventDefault();\n },\n isDefaultPrevented() {\n return e.isDefaultPrevented();\n },\n stopPropagation() {\n console.error(\n 'stopPropagation is now the default behavior for events in React Spectrum. You can use continuePropagation() to revert this behavior.'\n );\n },\n continuePropagation() {\n shouldStopPropagation = false;\n },\n };\n\n handler(event);\n\n if (shouldStopPropagation) {\n e.stopPropagation();\n }\n };\n}\n"],"names":["createEventHandler","handler","undefined","shouldStopPropagation","e","event","_objectSpread","preventDefault","isDefaultPrevented","stopPropagation","console","error","continuePropagation"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACO,SAASA,kBAAkBA,CAChCC,OAAmC,EACL;EAC9B,IAAI,CAACA,OAAO,EAAE;AACZ,IAAA,OAAOC,SAAS,CAAA;AAClB,GAAA;EAEA,IAAIC,qBAAqB,GAAG,IAAI,CAAA;AAChC,EAAA,OAAQC,CAAI,IAAK;AACf,IAAA,IAAIC,KAAmB,GAAAC,cAAA,CAAAA,cAAA,KAClBF,CAAC,CAAA,EAAA,EAAA,EAAA;AACJG,MAAAA,cAAcA,GAAG;QACfH,CAAC,CAACG,cAAc,EAAE,CAAA;OACnB;AACDC,MAAAA,kBAAkBA,GAAG;AACnB,QAAA,OAAOJ,CAAC,CAACI,kBAAkB,EAAE,CAAA;OAC9B;AACDC,MAAAA,eAAeA,GAAG;AAChBC,QAAAA,OAAO,CAACC,KAAK,CACX,sIACF,CAAC,CAAA;OACF;AACDC,MAAAA,mBAAmBA,GAAG;AACpBT,QAAAA,qBAAqB,GAAG,KAAK,CAAA;AAC/B,OAAA;KACD,CAAA,CAAA;IAEDF,OAAO,CAACI,KAAK,CAAC,CAAA;AAEd,IAAA,IAAIF,qBAAqB,EAAE;MACzBC,CAAC,CAACK,eAAe,EAAE,CAAA;AACrB,KAAA;GACD,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isIOS } from '../utils/platform.js';
|
|
2
|
+
import { getOwnerDocument } from '../utils/domHelpers.js';
|
|
3
|
+
import { runAfterTransition } from '../utils/runAfterTransition.js';
|
|
4
|
+
|
|
5
|
+
/* eslint-disable prefer-const */
|
|
6
|
+
|
|
7
|
+
// Safari on iOS starts selecting text on long press. The only way to avoid this, it seems,
|
|
8
|
+
// is to add user-select: none to the entire page. Adding it to the pressable element prevents
|
|
9
|
+
// that element from being selected, but nearby elements may still receive selection. We add
|
|
10
|
+
// user-select: none on touch start, and remove it again on touch end to prevent this.
|
|
11
|
+
// This must be implemented using global state to avoid race conditions between multiple elements.
|
|
12
|
+
|
|
13
|
+
// There are three possible states due to the delay before removing user-select: none after
|
|
14
|
+
// pointer up. The 'default' state always transitions to the 'disabled' state, which transitions
|
|
15
|
+
// to 'restoring'. The 'restoring' state can either transition back to 'disabled' or 'default'.
|
|
16
|
+
|
|
17
|
+
// For non-iOS devices, we apply user-select: none to the pressed element instead to avoid possible
|
|
18
|
+
// performance issues that arise from applying and removing user-select: none to the entire page
|
|
19
|
+
// (see https://github.com/adobe/react-spectrum/issues/1609).
|
|
20
|
+
// Note that state only matters here for iOS. Non-iOS gets user-select: none applied to the target element
|
|
21
|
+
// rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually
|
|
22
|
+
let state = 'default';
|
|
23
|
+
let savedUserSelect = '';
|
|
24
|
+
let modifiedElementMap = new WeakMap();
|
|
25
|
+
function disableTextSelection(target) {
|
|
26
|
+
if (isIOS()) {
|
|
27
|
+
if (state === 'default') {
|
|
28
|
+
// eslint-disable-next-line no-restricted-globals
|
|
29
|
+
const documentObject = getOwnerDocument(target);
|
|
30
|
+
savedUserSelect = documentObject.documentElement.style.webkitUserSelect;
|
|
31
|
+
documentObject.documentElement.style.webkitUserSelect = 'none';
|
|
32
|
+
}
|
|
33
|
+
state = 'disabled';
|
|
34
|
+
} else if (target instanceof HTMLElement || target instanceof SVGElement) {
|
|
35
|
+
// If not iOS, store the target's original user-select and change to user-select: none
|
|
36
|
+
// Ignore state since it doesn't apply for non iOS
|
|
37
|
+
modifiedElementMap.set(target, target.style.userSelect);
|
|
38
|
+
target.style.userSelect = 'none';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function restoreTextSelection(target) {
|
|
42
|
+
if (isIOS()) {
|
|
43
|
+
// If the state is already default, there's nothing to do.
|
|
44
|
+
// If it is restoring, then there's no need to queue a second restore.
|
|
45
|
+
if (state !== 'disabled') {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
state = 'restoring';
|
|
49
|
+
|
|
50
|
+
// There appears to be a delay on iOS where selection still might occur
|
|
51
|
+
// after pointer up, so wait a bit before removing user-select.
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
// Wait for any CSS transitions to complete so we don't recompute style
|
|
54
|
+
// for the whole page in the middle of the animation and cause jank.
|
|
55
|
+
runAfterTransition(() => {
|
|
56
|
+
// Avoid race conditions
|
|
57
|
+
if (state === 'restoring') {
|
|
58
|
+
// eslint-disable-next-line no-restricted-globals
|
|
59
|
+
const documentObject = getOwnerDocument(target);
|
|
60
|
+
if (documentObject.documentElement.style.webkitUserSelect === 'none') {
|
|
61
|
+
documentObject.documentElement.style.webkitUserSelect = savedUserSelect || '';
|
|
62
|
+
}
|
|
63
|
+
savedUserSelect = '';
|
|
64
|
+
state = 'default';
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}, 300);
|
|
68
|
+
} else if (target instanceof HTMLElement || target instanceof SVGElement) {
|
|
69
|
+
// If not iOS, restore the target's original user-select if any
|
|
70
|
+
// Ignore state since it doesn't apply for non iOS
|
|
71
|
+
if (target && modifiedElementMap.has(target)) {
|
|
72
|
+
let targetOldUserSelect = modifiedElementMap.get(target);
|
|
73
|
+
if (target.style.userSelect === 'none') {
|
|
74
|
+
target.style.userSelect = targetOldUserSelect;
|
|
75
|
+
}
|
|
76
|
+
if (target.getAttribute('style') === '') {
|
|
77
|
+
target.removeAttribute('style');
|
|
78
|
+
}
|
|
79
|
+
modifiedElementMap.delete(target);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { disableTextSelection, restoreTextSelection };
|
|
85
|
+
//# sourceMappingURL=textSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textSelection.js","sources":["../../../../src/react-aria/react-aria/interactions/textSelection.ts"],"sourcesContent":["/* eslint-disable prefer-const */\n// @ts-nocheck\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { getOwnerDocument, isIOS, runAfterTransition } from '../utils';\n\n// Safari on iOS starts selecting text on long press. The only way to avoid this, it seems,\n// is to add user-select: none to the entire page. Adding it to the pressable element prevents\n// that element from being selected, but nearby elements may still receive selection. We add\n// user-select: none on touch start, and remove it again on touch end to prevent this.\n// This must be implemented using global state to avoid race conditions between multiple elements.\n\n// There are three possible states due to the delay before removing user-select: none after\n// pointer up. The 'default' state always transitions to the 'disabled' state, which transitions\n// to 'restoring'. The 'restoring' state can either transition back to 'disabled' or 'default'.\n\n// For non-iOS devices, we apply user-select: none to the pressed element instead to avoid possible\n// performance issues that arise from applying and removing user-select: none to the entire page\n// (see https://github.com/adobe/react-spectrum/issues/1609).\ntype State = 'default' | 'disabled' | 'restoring';\n\n// Note that state only matters here for iOS. Non-iOS gets user-select: none applied to the target element\n// rather than at the document level so we just need to apply/remove user-select: none for each pressed element individually\nlet state: State = 'default';\nlet savedUserSelect = '';\nlet modifiedElementMap = new WeakMap<Element, string>();\n\nexport function disableTextSelection(target?: Element) {\n if (isIOS()) {\n if (state === 'default') {\n // eslint-disable-next-line no-restricted-globals\n const documentObject = getOwnerDocument(target);\n savedUserSelect = documentObject.documentElement.style.webkitUserSelect;\n documentObject.documentElement.style.webkitUserSelect = 'none';\n }\n\n state = 'disabled';\n } else if (target instanceof HTMLElement || target instanceof SVGElement) {\n // If not iOS, store the target's original user-select and change to user-select: none\n // Ignore state since it doesn't apply for non iOS\n modifiedElementMap.set(target, target.style.userSelect);\n target.style.userSelect = 'none';\n }\n}\n\nexport function restoreTextSelection(target?: Element) {\n if (isIOS()) {\n // If the state is already default, there's nothing to do.\n // If it is restoring, then there's no need to queue a second restore.\n if (state !== 'disabled') {\n return;\n }\n\n state = 'restoring';\n\n // There appears to be a delay on iOS where selection still might occur\n // after pointer up, so wait a bit before removing user-select.\n setTimeout(() => {\n // Wait for any CSS transitions to complete so we don't recompute style\n // for the whole page in the middle of the animation and cause jank.\n runAfterTransition(() => {\n // Avoid race conditions\n if (state === 'restoring') {\n // eslint-disable-next-line no-restricted-globals\n const documentObject = getOwnerDocument(target);\n if (documentObject.documentElement.style.webkitUserSelect === 'none') {\n documentObject.documentElement.style.webkitUserSelect = savedUserSelect || '';\n }\n\n savedUserSelect = '';\n state = 'default';\n }\n });\n }, 300);\n } else if (target instanceof HTMLElement || target instanceof SVGElement) {\n // If not iOS, restore the target's original user-select if any\n // Ignore state since it doesn't apply for non iOS\n if (target && modifiedElementMap.has(target)) {\n let targetOldUserSelect = modifiedElementMap.get(target) as string;\n\n if (target.style.userSelect === 'none') {\n target.style.userSelect = targetOldUserSelect;\n }\n\n if (target.getAttribute('style') === '') {\n target.removeAttribute('style');\n }\n modifiedElementMap.delete(target);\n }\n }\n}\n"],"names":["state","savedUserSelect","modifiedElementMap","WeakMap","disableTextSelection","target","isIOS","documentObject","getOwnerDocument","documentElement","style","webkitUserSelect","HTMLElement","SVGElement","set","userSelect","restoreTextSelection","setTimeout","runAfterTransition","has","targetOldUserSelect","get","getAttribute","removeAttribute","delete"],"mappings":";;;;AAAA;;AAgBA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AAGA;AACA;AACA,IAAIA,KAAY,GAAG,SAAS,CAAA;AAC5B,IAAIC,eAAe,GAAG,EAAE,CAAA;AACxB,IAAIC,kBAAkB,GAAG,IAAIC,OAAO,EAAmB,CAAA;AAEhD,SAASC,oBAAoBA,CAACC,MAAgB,EAAE;EACrD,IAAIC,KAAK,EAAE,EAAE;IACX,IAAIN,KAAK,KAAK,SAAS,EAAE;AACvB;AACA,MAAA,MAAMO,cAAc,GAAGC,gBAAgB,CAACH,MAAM,CAAC,CAAA;AAC/CJ,MAAAA,eAAe,GAAGM,cAAc,CAACE,eAAe,CAACC,KAAK,CAACC,gBAAgB,CAAA;AACvEJ,MAAAA,cAAc,CAACE,eAAe,CAACC,KAAK,CAACC,gBAAgB,GAAG,MAAM,CAAA;AAChE,KAAA;AAEAX,IAAAA,KAAK,GAAG,UAAU,CAAA;GACnB,MAAM,IAAIK,MAAM,YAAYO,WAAW,IAAIP,MAAM,YAAYQ,UAAU,EAAE;AACxE;AACA;IACAX,kBAAkB,CAACY,GAAG,CAACT,MAAM,EAAEA,MAAM,CAACK,KAAK,CAACK,UAAU,CAAC,CAAA;AACvDV,IAAAA,MAAM,CAACK,KAAK,CAACK,UAAU,GAAG,MAAM,CAAA;AAClC,GAAA;AACF,CAAA;AAEO,SAASC,oBAAoBA,CAACX,MAAgB,EAAE;EACrD,IAAIC,KAAK,EAAE,EAAE;AACX;AACA;IACA,IAAIN,KAAK,KAAK,UAAU,EAAE;AACxB,MAAA,OAAA;AACF,KAAA;AAEAA,IAAAA,KAAK,GAAG,WAAW,CAAA;;AAEnB;AACA;AACAiB,IAAAA,UAAU,CAAC,MAAM;AACf;AACA;AACAC,MAAAA,kBAAkB,CAAC,MAAM;AACvB;QACA,IAAIlB,KAAK,KAAK,WAAW,EAAE;AACzB;AACA,UAAA,MAAMO,cAAc,GAAGC,gBAAgB,CAACH,MAAM,CAAC,CAAA;UAC/C,IAAIE,cAAc,CAACE,eAAe,CAACC,KAAK,CAACC,gBAAgB,KAAK,MAAM,EAAE;YACpEJ,cAAc,CAACE,eAAe,CAACC,KAAK,CAACC,gBAAgB,GAAGV,eAAe,IAAI,EAAE,CAAA;AAC/E,WAAA;AAEAA,UAAAA,eAAe,GAAG,EAAE,CAAA;AACpBD,UAAAA,KAAK,GAAG,SAAS,CAAA;AACnB,SAAA;AACF,OAAC,CAAC,CAAA;KACH,EAAE,GAAG,CAAC,CAAA;GACR,MAAM,IAAIK,MAAM,YAAYO,WAAW,IAAIP,MAAM,YAAYQ,UAAU,EAAE;AACxE;AACA;IACA,IAAIR,MAAM,IAAIH,kBAAkB,CAACiB,GAAG,CAACd,MAAM,CAAC,EAAE;AAC5C,MAAA,IAAIe,mBAAmB,GAAGlB,kBAAkB,CAACmB,GAAG,CAAChB,MAAM,CAAW,CAAA;AAElE,MAAA,IAAIA,MAAM,CAACK,KAAK,CAACK,UAAU,KAAK,MAAM,EAAE;AACtCV,QAAAA,MAAM,CAACK,KAAK,CAACK,UAAU,GAAGK,mBAAmB,CAAA;AAC/C,OAAA;MAEA,IAAIf,MAAM,CAACiB,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE;AACvCjB,QAAAA,MAAM,CAACkB,eAAe,CAAC,OAAO,CAAC,CAAA;AACjC,OAAA;AACArB,MAAAA,kBAAkB,CAACsB,MAAM,CAACnB,MAAM,CAAC,CAAA;AACnC,KAAA;AACF,GAAA;AACF;;;;"}
|