@redsift/design-system 11.5.0-muiv5 → 11.6.0-muiv5-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +11 -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 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/react-aria/react-aria/numberfield/intl/index.ts"],"sourcesContent":["import enUS from './en-US.json';\nimport frFR from './fr-FR.json';\n\nexport default {\n 'en-US': enUS,\n 'fr-FR': frFR,\n};\n"],"names":["enUS","frFR"],"mappings":";;;AAGA,mBAAe;AACb,EAAA,OAAO,EAAEA,IAAI;AACb,EAAA,OAAO,EAAEC,IAAAA;AACX,CAAC;;;;"}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { useMemo, useState, useCallback } from 'react';
|
|
3
|
+
import intlMessages from './intl/index.js';
|
|
4
|
+
import { useMessageFormatter } from '../i18n/useMessageFormatter.js';
|
|
5
|
+
import { useId } from '../utils/useId.js';
|
|
6
|
+
import { useFocus } from '../interactions/useFocus.js';
|
|
7
|
+
import { useNumberFormatter } from '../i18n/useNumberFormatter.js';
|
|
8
|
+
import { useSpinButton } from '../spinbutton/useSpinButton.js';
|
|
9
|
+
import { useFocusWithin } from '../interactions/useFocusWithin.js';
|
|
10
|
+
import { useScrollWheel } from '../interactions/useScrollWheel.js';
|
|
11
|
+
import { isIPhone, isAndroid, isIOS } from '../utils/platform.js';
|
|
12
|
+
import { filterDOMProps } from '../utils/filterDOMProps.js';
|
|
13
|
+
import { useFormattedTextField } from '../textfield/useFormattedTextField.js';
|
|
14
|
+
import { privateValidationStateProp } from '../../react-stately/form/useFormValidationState.js';
|
|
15
|
+
import { chain } from '../utils/chain.js';
|
|
16
|
+
import { useFormReset } from '../utils/useFormReset.js';
|
|
17
|
+
import { mergeProps } from '../utils/mergeProps.js';
|
|
18
|
+
|
|
19
|
+
const _excluded = ["id", "decrementAriaLabel", "incrementAriaLabel", "isDisabled", "isReadOnly", "isRequired", "minValue", "maxValue", "autoFocus", "label", "formatOptions", "onBlur", "onFocus", "onFocusChange", "onKeyDown", "onKeyUp", "description", "errorMessage", "isWheelDisabled"];
|
|
20
|
+
/**
|
|
21
|
+
* Provides the behavior and accessibility implementation for a number field component.
|
|
22
|
+
* Number fields allow users to enter a number, and increment or decrement the value using stepper buttons.
|
|
23
|
+
*/
|
|
24
|
+
function useNumberField(props, state, inputRef) {
|
|
25
|
+
let {
|
|
26
|
+
id,
|
|
27
|
+
decrementAriaLabel,
|
|
28
|
+
incrementAriaLabel,
|
|
29
|
+
isDisabled,
|
|
30
|
+
isReadOnly,
|
|
31
|
+
isRequired,
|
|
32
|
+
minValue,
|
|
33
|
+
maxValue,
|
|
34
|
+
autoFocus,
|
|
35
|
+
label,
|
|
36
|
+
formatOptions,
|
|
37
|
+
onBlur = () => {},
|
|
38
|
+
onFocus,
|
|
39
|
+
onFocusChange,
|
|
40
|
+
onKeyDown,
|
|
41
|
+
onKeyUp,
|
|
42
|
+
description,
|
|
43
|
+
errorMessage,
|
|
44
|
+
isWheelDisabled
|
|
45
|
+
} = props,
|
|
46
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
47
|
+
let {
|
|
48
|
+
increment,
|
|
49
|
+
incrementToMax,
|
|
50
|
+
decrement,
|
|
51
|
+
decrementToMin,
|
|
52
|
+
numberValue,
|
|
53
|
+
inputValue,
|
|
54
|
+
commit,
|
|
55
|
+
commitValidation
|
|
56
|
+
} = state;
|
|
57
|
+
const format = useMessageFormatter(intlMessages);
|
|
58
|
+
let inputId = useId(id);
|
|
59
|
+
let {
|
|
60
|
+
focusProps
|
|
61
|
+
} = useFocus({
|
|
62
|
+
onBlur() {
|
|
63
|
+
// Set input value to normalized valid value
|
|
64
|
+
commit();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
let numberFormatter = useNumberFormatter(formatOptions);
|
|
68
|
+
let intlOptions = useMemo(() => numberFormatter.resolvedOptions(), [numberFormatter]);
|
|
69
|
+
|
|
70
|
+
// Replace negative textValue formatted using currencySign: 'accounting'
|
|
71
|
+
// with a textValue that can be announced using a minus sign.
|
|
72
|
+
let textValueFormatter = useNumberFormatter(_objectSpread2(_objectSpread2({}, formatOptions), {}, {
|
|
73
|
+
currencySign: undefined
|
|
74
|
+
}));
|
|
75
|
+
let textValue = useMemo(() => isNaN(numberValue) ? '' : textValueFormatter.format(numberValue), [textValueFormatter, numberValue]);
|
|
76
|
+
let {
|
|
77
|
+
spinButtonProps,
|
|
78
|
+
incrementButtonProps: incButtonProps,
|
|
79
|
+
decrementButtonProps: decButtonProps
|
|
80
|
+
} = useSpinButton({
|
|
81
|
+
isDisabled,
|
|
82
|
+
isReadOnly,
|
|
83
|
+
isRequired,
|
|
84
|
+
maxValue,
|
|
85
|
+
minValue,
|
|
86
|
+
onIncrement: increment,
|
|
87
|
+
onIncrementToMax: incrementToMax,
|
|
88
|
+
onDecrement: decrement,
|
|
89
|
+
onDecrementToMin: decrementToMin,
|
|
90
|
+
value: numberValue,
|
|
91
|
+
textValue
|
|
92
|
+
});
|
|
93
|
+
let [focusWithin, setFocusWithin] = useState(false);
|
|
94
|
+
let {
|
|
95
|
+
focusWithinProps
|
|
96
|
+
} = useFocusWithin({
|
|
97
|
+
isDisabled,
|
|
98
|
+
onFocusWithinChange: setFocusWithin
|
|
99
|
+
});
|
|
100
|
+
let onWheel = useCallback(e => {
|
|
101
|
+
// if on a trackpad, users can scroll in both X and Y at once, check the magnitude of the change
|
|
102
|
+
// if it's mostly in the X direction, then just return, the user probably doesn't mean to inc/dec
|
|
103
|
+
// this isn't perfect, events come in fast with small deltas and a part of the scroll may give a false indication
|
|
104
|
+
// especially if the user is scrolling near 45deg
|
|
105
|
+
if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (e.deltaY > 0) {
|
|
109
|
+
increment();
|
|
110
|
+
} else if (e.deltaY < 0) {
|
|
111
|
+
decrement();
|
|
112
|
+
}
|
|
113
|
+
}, [decrement, increment]);
|
|
114
|
+
// If the input isn't supposed to receive input, disable scrolling.
|
|
115
|
+
let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;
|
|
116
|
+
useScrollWheel({
|
|
117
|
+
onScroll: onWheel,
|
|
118
|
+
isDisabled: scrollingDisabled
|
|
119
|
+
}, inputRef);
|
|
120
|
+
|
|
121
|
+
// The inputMode attribute influences the software keyboard that is shown on touch devices.
|
|
122
|
+
// Browsers and operating systems are quite inconsistent about what keys are available, however.
|
|
123
|
+
// We choose between numeric and decimal based on whether we allow negative and fractional numbers,
|
|
124
|
+
// and based on testing on various devices to determine what keys are available in each inputMode.
|
|
125
|
+
let hasDecimals = intlOptions.maximumFractionDigits > 0;
|
|
126
|
+
let hasNegative = state.minValue === undefined || isNaN(state.minValue) || state.minValue < 0;
|
|
127
|
+
let inputMode = 'numeric';
|
|
128
|
+
if (isIPhone()) {
|
|
129
|
+
// iPhone doesn't have a minus sign in either numeric or decimal.
|
|
130
|
+
// Note this is only for iPhone, not iPad, which always has both
|
|
131
|
+
// minus and decimal in numeric.
|
|
132
|
+
if (hasNegative) {
|
|
133
|
+
inputMode = 'text';
|
|
134
|
+
} else if (hasDecimals) {
|
|
135
|
+
inputMode = 'decimal';
|
|
136
|
+
}
|
|
137
|
+
} else if (isAndroid()) {
|
|
138
|
+
// Android numeric has both a decimal point and minus key.
|
|
139
|
+
// decimal does not have a minus key.
|
|
140
|
+
if (hasNegative) {
|
|
141
|
+
inputMode = 'numeric';
|
|
142
|
+
} else if (hasDecimals) {
|
|
143
|
+
inputMode = 'decimal';
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
let onChange = value => {
|
|
147
|
+
if (state.validate(value)) {
|
|
148
|
+
state.setInputValue(value);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
let domProps = filterDOMProps(props);
|
|
152
|
+
let onKeyDownEnter = useCallback(e => {
|
|
153
|
+
if (e.key === 'Enter') {
|
|
154
|
+
commit();
|
|
155
|
+
commitValidation();
|
|
156
|
+
} else {
|
|
157
|
+
e.continuePropagation();
|
|
158
|
+
}
|
|
159
|
+
}, [commit, commitValidation]);
|
|
160
|
+
let {
|
|
161
|
+
isInvalid,
|
|
162
|
+
validationErrors,
|
|
163
|
+
validationDetails
|
|
164
|
+
} = state.displayValidation;
|
|
165
|
+
let {
|
|
166
|
+
labelProps,
|
|
167
|
+
inputProps: textFieldProps,
|
|
168
|
+
descriptionProps,
|
|
169
|
+
errorMessageProps
|
|
170
|
+
} = useFormattedTextField(_objectSpread2(_objectSpread2(_objectSpread2({}, otherProps), domProps), {}, {
|
|
171
|
+
name: undefined,
|
|
172
|
+
label,
|
|
173
|
+
autoFocus,
|
|
174
|
+
isDisabled,
|
|
175
|
+
isReadOnly,
|
|
176
|
+
isRequired,
|
|
177
|
+
validate: undefined,
|
|
178
|
+
[privateValidationStateProp]: state,
|
|
179
|
+
value: inputValue,
|
|
180
|
+
defaultValue: undefined,
|
|
181
|
+
// defaultValue already used to populate state.inputValue, unneeded here
|
|
182
|
+
autoComplete: 'off',
|
|
183
|
+
'aria-label': props['aria-label'] || undefined,
|
|
184
|
+
'aria-labelledby': props['aria-labelledby'] || undefined,
|
|
185
|
+
id: inputId,
|
|
186
|
+
type: 'text',
|
|
187
|
+
// Can't use type="number" because then we can't have things like $ in the field.
|
|
188
|
+
inputMode,
|
|
189
|
+
onChange,
|
|
190
|
+
onBlur,
|
|
191
|
+
onFocus,
|
|
192
|
+
onFocusChange,
|
|
193
|
+
onKeyDown: useMemo(() => chain(onKeyDownEnter, onKeyDown), [onKeyDownEnter, onKeyDown]),
|
|
194
|
+
onKeyUp,
|
|
195
|
+
description,
|
|
196
|
+
errorMessage
|
|
197
|
+
}), state, inputRef);
|
|
198
|
+
useFormReset(inputRef, state.numberValue, state.setNumberValue);
|
|
199
|
+
let inputProps = mergeProps(spinButtonProps, focusProps, textFieldProps, {
|
|
200
|
+
// override the spinbutton role, we can't focus a spin button with VO
|
|
201
|
+
role: null,
|
|
202
|
+
// ignore aria-roledescription on iOS so that required state will announce when it is present
|
|
203
|
+
'aria-roledescription': !isIOS() ? format('numberField') : null,
|
|
204
|
+
'aria-valuemax': null,
|
|
205
|
+
'aria-valuemin': null,
|
|
206
|
+
'aria-valuenow': null,
|
|
207
|
+
'aria-valuetext': null,
|
|
208
|
+
autoCorrect: 'off',
|
|
209
|
+
spellCheck: 'false'
|
|
210
|
+
});
|
|
211
|
+
if (props.validationBehavior === 'native') {
|
|
212
|
+
inputProps['aria-required'] = undefined;
|
|
213
|
+
}
|
|
214
|
+
let onButtonPressStart = e => {
|
|
215
|
+
// If focus is already on the input, keep it there so we don't hide the
|
|
216
|
+
// software keyboard when tapping the increment/decrement buttons.
|
|
217
|
+
if (document.activeElement === inputRef.current) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Otherwise, when using a mouse, move focus to the input.
|
|
222
|
+
// On touch, or with a screen reader, focus the button so that the software
|
|
223
|
+
// keyboard does not appear and the screen reader cursor is not moved off the button.
|
|
224
|
+
if (e.pointerType === 'mouse') {
|
|
225
|
+
var _inputRef$current;
|
|
226
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
227
|
+
} else {
|
|
228
|
+
e.target.focus();
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
// Determine the label for the increment and decrement buttons. There are 4 cases:
|
|
233
|
+
//
|
|
234
|
+
// 1. With a visible label that is a string: aria-label: `Increase ${props.label}`
|
|
235
|
+
// 2. With a visible label that is JSX: aria-label: 'Increase', aria-labelledby: '${incrementId} ${labelId}'
|
|
236
|
+
// 3. With an aria-label: aria-label: `Increase ${props['aria-label']}`
|
|
237
|
+
// 4. With an aria-labelledby: aria-label: 'Increase', aria-labelledby: `${incrementId} ${props['aria-labelledby']}`
|
|
238
|
+
//
|
|
239
|
+
// (1) and (2) could possibly be combined and both use aria-labelledby. However, placing the label in
|
|
240
|
+
// the aria-label string rather than using aria-labelledby gives more flexibility to translators to change
|
|
241
|
+
// the order or add additional words around the label if needed.
|
|
242
|
+
let fieldLabel = props['aria-label'] || (typeof props.label === 'string' ? props.label : '');
|
|
243
|
+
let ariaLabelledby;
|
|
244
|
+
if (!fieldLabel) {
|
|
245
|
+
ariaLabelledby = props.label != null ? labelProps.id : props['aria-labelledby'];
|
|
246
|
+
}
|
|
247
|
+
let incrementId = useId();
|
|
248
|
+
let decrementId = useId();
|
|
249
|
+
let incrementButtonProps = mergeProps(incButtonProps, {
|
|
250
|
+
'aria-label': incrementAriaLabel || format('increase', {
|
|
251
|
+
fieldLabel
|
|
252
|
+
}).trim(),
|
|
253
|
+
id: ariaLabelledby && !incrementAriaLabel ? incrementId : null,
|
|
254
|
+
'aria-labelledby': ariaLabelledby && !incrementAriaLabel ? `${incrementId} ${ariaLabelledby}` : null,
|
|
255
|
+
'aria-controls': inputId,
|
|
256
|
+
excludeFromTabOrder: true,
|
|
257
|
+
preventFocusOnPress: true,
|
|
258
|
+
allowFocusWhenDisabled: true,
|
|
259
|
+
isDisabled: !state.canIncrement,
|
|
260
|
+
onPressStart: onButtonPressStart
|
|
261
|
+
});
|
|
262
|
+
let decrementButtonProps = mergeProps(decButtonProps, {
|
|
263
|
+
'aria-label': decrementAriaLabel || format('decrease', {
|
|
264
|
+
fieldLabel
|
|
265
|
+
}).trim(),
|
|
266
|
+
id: ariaLabelledby && !decrementAriaLabel ? decrementId : null,
|
|
267
|
+
'aria-labelledby': ariaLabelledby && !decrementAriaLabel ? `${decrementId} ${ariaLabelledby}` : null,
|
|
268
|
+
'aria-controls': inputId,
|
|
269
|
+
excludeFromTabOrder: true,
|
|
270
|
+
preventFocusOnPress: true,
|
|
271
|
+
allowFocusWhenDisabled: true,
|
|
272
|
+
isDisabled: !state.canDecrement,
|
|
273
|
+
onPressStart: onButtonPressStart
|
|
274
|
+
});
|
|
275
|
+
return {
|
|
276
|
+
groupProps: _objectSpread2(_objectSpread2({}, focusWithinProps), {}, {
|
|
277
|
+
role: 'group',
|
|
278
|
+
'aria-disabled': isDisabled,
|
|
279
|
+
'aria-invalid': isInvalid ? 'true' : undefined
|
|
280
|
+
}),
|
|
281
|
+
labelProps,
|
|
282
|
+
inputProps,
|
|
283
|
+
incrementButtonProps,
|
|
284
|
+
decrementButtonProps,
|
|
285
|
+
errorMessageProps,
|
|
286
|
+
descriptionProps,
|
|
287
|
+
isInvalid,
|
|
288
|
+
validationErrors,
|
|
289
|
+
validationDetails
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export { useNumberField };
|
|
294
|
+
//# sourceMappingURL=useNumberField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNumberField.js","sources":["../../../../src/react-aria/react-aria/numberfield/useNumberField.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 { AriaButtonProps } from '../../react-types/button';\nimport { AriaNumberFieldProps } from '../../react-types/numberfield';\nimport { chain, filterDOMProps, isAndroid, isIOS, isIPhone, mergeProps, useFormReset, useId } from '../utils';\nimport { DOMAttributes, GroupDOMAttributes, TextInputDOMProps, ValidationResult } from '../../react-types/shared';\nimport { InputHTMLAttributes, LabelHTMLAttributes, RefObject, useCallback, useMemo, useState } from 'react';\n// @ts-ignore\nimport intlMessages from './intl';\nimport { NumberFieldState } from '../../react-stately/numberfield';\nimport { privateValidationStateProp } from '../../react-stately/form';\nimport { useFocus, useFocusWithin, useScrollWheel } from '../interactions';\nimport { useFormattedTextField } from '../textfield';\nimport { useMessageFormatter, useNumberFormatter } from '../i18n';\nimport { useSpinButton } from '../spinbutton';\n\nexport interface NumberFieldAria extends ValidationResult {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>;\n /** Props for the group wrapper around the input and stepper buttons. */\n groupProps: GroupDOMAttributes;\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the increment button, to be passed to [useButton](useButton.html). */\n incrementButtonProps: AriaButtonProps;\n /** Props for the decrement button, to be passed to [useButton](useButton.html). */\n decrementButtonProps: AriaButtonProps;\n /** Props for the number field's description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the number field's error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a number field component.\n * Number fields allow users to enter a number, and increment or decrement the value using stepper buttons.\n */\nexport function useNumberField(\n props: AriaNumberFieldProps,\n state: NumberFieldState,\n inputRef: RefObject<HTMLInputElement>\n): NumberFieldAria {\n let {\n id,\n decrementAriaLabel,\n incrementAriaLabel,\n isDisabled,\n isReadOnly,\n isRequired,\n minValue,\n maxValue,\n autoFocus,\n label,\n formatOptions,\n onBlur = () => {},\n onFocus,\n onFocusChange,\n onKeyDown,\n onKeyUp,\n description,\n errorMessage,\n isWheelDisabled,\n ...otherProps\n } = props;\n\n let { increment, incrementToMax, decrement, decrementToMin, numberValue, inputValue, commit, commitValidation } =\n state;\n\n const format = useMessageFormatter(intlMessages);\n\n let inputId = useId(id);\n let { focusProps } = useFocus({\n onBlur() {\n // Set input value to normalized valid value\n commit();\n },\n });\n\n let numberFormatter = useNumberFormatter(formatOptions);\n let intlOptions = useMemo(() => numberFormatter.resolvedOptions(), [numberFormatter]);\n\n // Replace negative textValue formatted using currencySign: 'accounting'\n // with a textValue that can be announced using a minus sign.\n let textValueFormatter = useNumberFormatter({ ...formatOptions, currencySign: undefined });\n let textValue = useMemo(\n () => (isNaN(numberValue) ? '' : textValueFormatter.format(numberValue)),\n [textValueFormatter, numberValue]\n );\n\n let {\n spinButtonProps,\n incrementButtonProps: incButtonProps,\n decrementButtonProps: decButtonProps,\n } = useSpinButton({\n isDisabled,\n isReadOnly,\n isRequired,\n maxValue,\n minValue,\n onIncrement: increment,\n onIncrementToMax: incrementToMax,\n onDecrement: decrement,\n onDecrementToMin: decrementToMin,\n value: numberValue,\n textValue,\n });\n\n let [focusWithin, setFocusWithin] = useState(false);\n let { focusWithinProps } = useFocusWithin({ isDisabled, onFocusWithinChange: setFocusWithin });\n\n let onWheel = useCallback(\n (e) => {\n // if on a trackpad, users can scroll in both X and Y at once, check the magnitude of the change\n // if it's mostly in the X direction, then just return, the user probably doesn't mean to inc/dec\n // this isn't perfect, events come in fast with small deltas and a part of the scroll may give a false indication\n // especially if the user is scrolling near 45deg\n if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) {\n return;\n }\n if (e.deltaY > 0) {\n increment();\n } else if (e.deltaY < 0) {\n decrement();\n }\n },\n [decrement, increment]\n );\n // If the input isn't supposed to receive input, disable scrolling.\n let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;\n useScrollWheel({ onScroll: onWheel, isDisabled: scrollingDisabled }, inputRef);\n\n // The inputMode attribute influences the software keyboard that is shown on touch devices.\n // Browsers and operating systems are quite inconsistent about what keys are available, however.\n // We choose between numeric and decimal based on whether we allow negative and fractional numbers,\n // and based on testing on various devices to determine what keys are available in each inputMode.\n let hasDecimals = intlOptions.maximumFractionDigits > 0;\n let hasNegative = state.minValue === undefined || isNaN(state.minValue) || state.minValue < 0;\n let inputMode: TextInputDOMProps['inputMode'] = 'numeric';\n if (isIPhone()) {\n // iPhone doesn't have a minus sign in either numeric or decimal.\n // Note this is only for iPhone, not iPad, which always has both\n // minus and decimal in numeric.\n if (hasNegative) {\n inputMode = 'text';\n } else if (hasDecimals) {\n inputMode = 'decimal';\n }\n } else if (isAndroid()) {\n // Android numeric has both a decimal point and minus key.\n // decimal does not have a minus key.\n if (hasNegative) {\n inputMode = 'numeric';\n } else if (hasDecimals) {\n inputMode = 'decimal';\n }\n }\n\n let onChange = (value) => {\n if (state.validate(value)) {\n state.setInputValue(value);\n }\n };\n\n let domProps = filterDOMProps(props);\n let onKeyDownEnter = useCallback(\n (e) => {\n if (e.key === 'Enter') {\n commit();\n commitValidation();\n } else {\n e.continuePropagation();\n }\n },\n [commit, commitValidation]\n );\n\n let { isInvalid, validationErrors, validationDetails } = state.displayValidation;\n let {\n labelProps,\n inputProps: textFieldProps,\n descriptionProps,\n errorMessageProps,\n } = useFormattedTextField(\n {\n ...otherProps,\n ...domProps,\n name: undefined,\n label,\n autoFocus,\n isDisabled,\n isReadOnly,\n isRequired,\n validate: undefined,\n [privateValidationStateProp]: state,\n value: inputValue,\n defaultValue: undefined, // defaultValue already used to populate state.inputValue, unneeded here\n autoComplete: 'off',\n 'aria-label': props['aria-label'] || undefined,\n 'aria-labelledby': props['aria-labelledby'] || undefined,\n id: inputId,\n type: 'text', // Can't use type=\"number\" because then we can't have things like $ in the field.\n inputMode,\n onChange,\n onBlur,\n onFocus,\n onFocusChange,\n onKeyDown: useMemo(() => chain(onKeyDownEnter, onKeyDown), [onKeyDownEnter, onKeyDown]),\n onKeyUp,\n description,\n errorMessage,\n },\n state,\n inputRef\n );\n\n useFormReset(inputRef, state.numberValue, state.setNumberValue);\n\n let inputProps: InputHTMLAttributes<HTMLInputElement> = mergeProps(spinButtonProps, focusProps, textFieldProps, {\n // override the spinbutton role, we can't focus a spin button with VO\n role: null,\n // ignore aria-roledescription on iOS so that required state will announce when it is present\n 'aria-roledescription': !isIOS() ? format('numberField') : null,\n 'aria-valuemax': null,\n 'aria-valuemin': null,\n 'aria-valuenow': null,\n 'aria-valuetext': null,\n autoCorrect: 'off',\n spellCheck: 'false',\n });\n\n if (props.validationBehavior === 'native') {\n inputProps['aria-required'] = undefined;\n }\n\n let onButtonPressStart = (e) => {\n // If focus is already on the input, keep it there so we don't hide the\n // software keyboard when tapping the increment/decrement buttons.\n if (document.activeElement === inputRef.current) {\n return;\n }\n\n // Otherwise, when using a mouse, move focus to the input.\n // On touch, or with a screen reader, focus the button so that the software\n // keyboard does not appear and the screen reader cursor is not moved off the button.\n if (e.pointerType === 'mouse') {\n inputRef.current?.focus();\n } else {\n e.target.focus();\n }\n };\n\n // Determine the label for the increment and decrement buttons. There are 4 cases:\n //\n // 1. With a visible label that is a string: aria-label: `Increase ${props.label}`\n // 2. With a visible label that is JSX: aria-label: 'Increase', aria-labelledby: '${incrementId} ${labelId}'\n // 3. With an aria-label: aria-label: `Increase ${props['aria-label']}`\n // 4. With an aria-labelledby: aria-label: 'Increase', aria-labelledby: `${incrementId} ${props['aria-labelledby']}`\n //\n // (1) and (2) could possibly be combined and both use aria-labelledby. However, placing the label in\n // the aria-label string rather than using aria-labelledby gives more flexibility to translators to change\n // the order or add additional words around the label if needed.\n let fieldLabel = props['aria-label'] || (typeof props.label === 'string' ? props.label : '');\n let ariaLabelledby: string | undefined;\n if (!fieldLabel) {\n ariaLabelledby = props.label != null ? labelProps.id : props['aria-labelledby'];\n }\n\n let incrementId = useId();\n let decrementId = useId();\n\n let incrementButtonProps: AriaButtonProps = mergeProps(incButtonProps, {\n 'aria-label': incrementAriaLabel || format('increase', { fieldLabel }).trim(),\n id: ariaLabelledby && !incrementAriaLabel ? incrementId : null,\n 'aria-labelledby': ariaLabelledby && !incrementAriaLabel ? `${incrementId} ${ariaLabelledby}` : null,\n 'aria-controls': inputId,\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n allowFocusWhenDisabled: true,\n isDisabled: !state.canIncrement,\n onPressStart: onButtonPressStart,\n });\n\n let decrementButtonProps: AriaButtonProps = mergeProps(decButtonProps, {\n 'aria-label': decrementAriaLabel || format('decrease', { fieldLabel }).trim(),\n id: ariaLabelledby && !decrementAriaLabel ? decrementId : null,\n 'aria-labelledby': ariaLabelledby && !decrementAriaLabel ? `${decrementId} ${ariaLabelledby}` : null,\n 'aria-controls': inputId,\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n allowFocusWhenDisabled: true,\n isDisabled: !state.canDecrement,\n onPressStart: onButtonPressStart,\n });\n\n return {\n groupProps: {\n ...focusWithinProps,\n role: 'group',\n 'aria-disabled': isDisabled,\n 'aria-invalid': isInvalid ? 'true' : undefined,\n },\n labelProps,\n inputProps,\n incrementButtonProps,\n decrementButtonProps,\n errorMessageProps,\n descriptionProps,\n isInvalid,\n validationErrors,\n validationDetails,\n };\n}\n"],"names":["useNumberField","props","state","inputRef","id","decrementAriaLabel","incrementAriaLabel","isDisabled","isReadOnly","isRequired","minValue","maxValue","autoFocus","label","formatOptions","onBlur","onFocus","onFocusChange","onKeyDown","onKeyUp","description","errorMessage","isWheelDisabled","otherProps","_objectWithoutProperties","_excluded","increment","incrementToMax","decrement","decrementToMin","numberValue","inputValue","commit","commitValidation","format","useMessageFormatter","intlMessages","inputId","useId","focusProps","useFocus","numberFormatter","useNumberFormatter","intlOptions","useMemo","resolvedOptions","textValueFormatter","_objectSpread","currencySign","undefined","textValue","isNaN","spinButtonProps","incrementButtonProps","incButtonProps","decrementButtonProps","decButtonProps","useSpinButton","onIncrement","onIncrementToMax","onDecrement","onDecrementToMin","value","focusWithin","setFocusWithin","useState","focusWithinProps","useFocusWithin","onFocusWithinChange","onWheel","useCallback","e","Math","abs","deltaY","deltaX","scrollingDisabled","useScrollWheel","onScroll","hasDecimals","maximumFractionDigits","hasNegative","inputMode","isIPhone","isAndroid","onChange","validate","setInputValue","domProps","filterDOMProps","onKeyDownEnter","key","continuePropagation","isInvalid","validationErrors","validationDetails","displayValidation","labelProps","inputProps","textFieldProps","descriptionProps","errorMessageProps","useFormattedTextField","name","privateValidationStateProp","defaultValue","autoComplete","type","chain","useFormReset","setNumberValue","mergeProps","role","isIOS","autoCorrect","spellCheck","validationBehavior","onButtonPressStart","document","activeElement","current","pointerType","_inputRef$current","focus","target","fieldLabel","ariaLabelledby","incrementId","decrementId","trim","excludeFromTabOrder","preventFocusOnPress","allowFocusWhenDisabled","canIncrement","onPressStart","canDecrement","groupProps"],"mappings":";;;;;;;;;;;;;;;;;;;AA6CA;AACA;AACA;AACA;AACO,SAASA,cAAcA,CAC5BC,KAA2B,EAC3BC,KAAuB,EACvBC,QAAqC,EACpB;EACjB,IAAI;MACFC,EAAE;MACFC,kBAAkB;MAClBC,kBAAkB;MAClBC,UAAU;MACVC,UAAU;MACVC,UAAU;MACVC,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EF,EAAA,IAAI9D,oBAAqC,GAAGwD,UAAU,CAACvD,cAAc,EAAE;AACrE,IAAA,YAAY,EAAEnD,kBAAkB,IAAI6B,MAAM,CAAC,UAAU,EAAE;AAAE2F,MAAAA,UAAAA;AAAW,KAAC,CAAC,CAACI,IAAI,EAAE;IAC7E7H,EAAE,EAAE0H,cAAc,IAAI,CAACzH,kBAAkB,GAAG2H,WAAW,GAAG,IAAI;AAC9D,IAAA,iBAAiB,EAAEF,cAAc,IAAI,CAACzH,kBAAkB,GAAI,CAAE2H,EAAAA,WAAY,CAAGF,CAAAA,EAAAA,cAAe,CAAC,CAAA,GAAG,IAAI;AACpG,IAAA,eAAe,EAAEzF,OAAO;AACxB6F,IAAAA,mBAAmB,EAAE,IAAI;AACzBC,IAAAA,mBAAmB,EAAE,IAAI;AACzBC,IAAAA,sBAAsB,EAAE,IAAI;AAC5B7H,IAAAA,UAAU,EAAE,CAACL,KAAK,CAACqI,YAAY;AAC/BD,IAAAA,YAAY,EAAEjB,kBAAAA;AAChB,GAAC,CAAC,CAAA;EAEF,OAAO;AACLmB,IAAAA,UAAU,EAAAzF,cAAA,CAAAA,cAAA,KACLmB,gBAAgB,CAAA,EAAA,EAAA,EAAA;AACnB8C,MAAAA,IAAI,EAAE,OAAO;AACb,MAAA,eAAe,EAAEzG,UAAU;AAC3B,MAAA,cAAc,EAAEsF,SAAS,GAAG,MAAM,GAAG5C,SAAAA;KACtC,CAAA;IACDgD,UAAU;IACVC,UAAU;IACV7C,oBAAoB;IACpBE,oBAAoB;IACpB8C,iBAAiB;IACjBD,gBAAgB;IAChBP,SAAS;IACTC,gBAAgB;AAChBC,IAAAA,iBAAAA;GACD,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en-US.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fr-FR.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/react-aria/react-aria/spinbutton/intl/index.ts"],"sourcesContent":["import enUS from './en-US.json';\nimport frFR from './fr-FR.json';\n\nexport default {\n 'en-US': enUS,\n 'fr-FR': frFR,\n};\n"],"names":["enUS","frFR"],"mappings":";;;AAGA,mBAAe;AACb,EAAA,OAAO,EAAEA,IAAI;AACb,EAAA,OAAO,EAAEC,IAAAA;AACX,CAAC;;;;"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import intlMessages from './intl/index.js';
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
import { useMessageFormatter } from '../i18n/useMessageFormatter.js';
|
|
4
|
+
import { clearAnnouncer, announce } from '../live-announcer/LiveAnnouncer.js';
|
|
5
|
+
import { useEffectEvent } from '../utils/useEffectEvent.js';
|
|
6
|
+
import { useGlobalListeners } from '../utils/useGlobalListeners.js';
|
|
7
|
+
|
|
8
|
+
/* eslint-disable prefer-const */
|
|
9
|
+
function useSpinButton(props) {
|
|
10
|
+
const _async = useRef();
|
|
11
|
+
let {
|
|
12
|
+
value,
|
|
13
|
+
textValue,
|
|
14
|
+
minValue,
|
|
15
|
+
maxValue,
|
|
16
|
+
isDisabled,
|
|
17
|
+
isReadOnly,
|
|
18
|
+
isRequired,
|
|
19
|
+
onIncrement,
|
|
20
|
+
onIncrementPage,
|
|
21
|
+
onDecrement,
|
|
22
|
+
onDecrementPage,
|
|
23
|
+
onDecrementToMin,
|
|
24
|
+
onIncrementToMax
|
|
25
|
+
} = props;
|
|
26
|
+
const format = useMessageFormatter(intlMessages);
|
|
27
|
+
const clearAsync = () => clearTimeout(_async.current);
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line arrow-body-style
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
return () => clearAsync();
|
|
32
|
+
}, []);
|
|
33
|
+
let onKeyDown = e => {
|
|
34
|
+
if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || isReadOnly) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
switch (e.key) {
|
|
38
|
+
case 'PageUp':
|
|
39
|
+
if (onIncrementPage) {
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
onIncrementPage === null || onIncrementPage === void 0 ? void 0 : onIncrementPage();
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
// fallthrough!
|
|
45
|
+
case 'ArrowUp':
|
|
46
|
+
case 'Up':
|
|
47
|
+
if (onIncrement) {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
onIncrement === null || onIncrement === void 0 ? void 0 : onIncrement();
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case 'PageDown':
|
|
53
|
+
if (onDecrementPage) {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
onDecrementPage === null || onDecrementPage === void 0 ? void 0 : onDecrementPage();
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
// fallthrough
|
|
59
|
+
case 'ArrowDown':
|
|
60
|
+
case 'Down':
|
|
61
|
+
if (onDecrement) {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
onDecrement === null || onDecrement === void 0 ? void 0 : onDecrement();
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case 'Home':
|
|
67
|
+
if (onDecrementToMin) {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
onDecrementToMin === null || onDecrementToMin === void 0 ? void 0 : onDecrementToMin();
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
case 'End':
|
|
73
|
+
if (onIncrementToMax) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
onIncrementToMax === null || onIncrementToMax === void 0 ? void 0 : onIncrementToMax();
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
let isFocused = useRef(false);
|
|
81
|
+
let onFocus = () => {
|
|
82
|
+
isFocused.current = true;
|
|
83
|
+
};
|
|
84
|
+
let onBlur = () => {
|
|
85
|
+
isFocused.current = false;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Replace Unicode hyphen-minus (U+002D) with minus sign (U+2212).
|
|
89
|
+
// This ensures that macOS VoiceOver announces it as "minus" even with other characters between the minus sign
|
|
90
|
+
// and the number (e.g. currency symbol). Otherwise it announces nothing because it assumes the character is a hyphen.
|
|
91
|
+
// In addition, replace the empty string with the word "Empty" so that iOS VoiceOver does not read "50%" for an empty field.
|
|
92
|
+
let ariaTextValue = textValue === '' ? format('Empty') : (textValue || `${value}`).replace('-', '\u2212');
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (isFocused.current) {
|
|
95
|
+
clearAnnouncer('assertive');
|
|
96
|
+
announce(ariaTextValue, 'assertive');
|
|
97
|
+
}
|
|
98
|
+
}, [ariaTextValue]);
|
|
99
|
+
const onIncrementPressStart = useEffectEvent(initialStepDelay => {
|
|
100
|
+
clearAsync();
|
|
101
|
+
onIncrement === null || onIncrement === void 0 ? void 0 : onIncrement();
|
|
102
|
+
// Start spinning after initial delay
|
|
103
|
+
_async.current = window.setTimeout(() => {
|
|
104
|
+
if (maxValue === undefined || isNaN(maxValue) || value === undefined || isNaN(value) || value < maxValue) {
|
|
105
|
+
onIncrementPressStart(60);
|
|
106
|
+
}
|
|
107
|
+
}, initialStepDelay);
|
|
108
|
+
});
|
|
109
|
+
const onDecrementPressStart = useEffectEvent(initialStepDelay => {
|
|
110
|
+
clearAsync();
|
|
111
|
+
onDecrement === null || onDecrement === void 0 ? void 0 : onDecrement();
|
|
112
|
+
// Start spinning after initial delay
|
|
113
|
+
_async.current = window.setTimeout(() => {
|
|
114
|
+
if (minValue === undefined || isNaN(minValue) || value === undefined || isNaN(value) || value > minValue) {
|
|
115
|
+
onDecrementPressStart(60);
|
|
116
|
+
}
|
|
117
|
+
}, initialStepDelay);
|
|
118
|
+
});
|
|
119
|
+
let cancelContextMenu = e => {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
};
|
|
122
|
+
let {
|
|
123
|
+
addGlobalListener,
|
|
124
|
+
removeAllGlobalListeners
|
|
125
|
+
} = useGlobalListeners();
|
|
126
|
+
return {
|
|
127
|
+
spinButtonProps: {
|
|
128
|
+
role: 'spinbutton',
|
|
129
|
+
'aria-valuenow': value !== undefined && !isNaN(value) ? value : undefined,
|
|
130
|
+
'aria-valuetext': ariaTextValue,
|
|
131
|
+
'aria-valuemin': minValue,
|
|
132
|
+
'aria-valuemax': maxValue,
|
|
133
|
+
'aria-disabled': isDisabled || undefined,
|
|
134
|
+
'aria-readonly': isReadOnly || undefined,
|
|
135
|
+
'aria-required': isRequired || undefined,
|
|
136
|
+
onKeyDown,
|
|
137
|
+
onFocus,
|
|
138
|
+
onBlur
|
|
139
|
+
},
|
|
140
|
+
incrementButtonProps: {
|
|
141
|
+
onPressStart: () => {
|
|
142
|
+
onIncrementPressStart(400);
|
|
143
|
+
addGlobalListener(window, 'contextmenu', cancelContextMenu);
|
|
144
|
+
},
|
|
145
|
+
onPressEnd: () => {
|
|
146
|
+
clearAsync();
|
|
147
|
+
removeAllGlobalListeners();
|
|
148
|
+
},
|
|
149
|
+
onFocus,
|
|
150
|
+
onBlur
|
|
151
|
+
},
|
|
152
|
+
decrementButtonProps: {
|
|
153
|
+
onPressStart: () => {
|
|
154
|
+
onDecrementPressStart(400);
|
|
155
|
+
addGlobalListener(window, 'contextmenu', cancelContextMenu);
|
|
156
|
+
},
|
|
157
|
+
onPressEnd: () => {
|
|
158
|
+
clearAsync();
|
|
159
|
+
removeAllGlobalListeners();
|
|
160
|
+
},
|
|
161
|
+
onFocus,
|
|
162
|
+
onBlur
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export { useSpinButton };
|
|
168
|
+
//# sourceMappingURL=useSpinButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSpinButton.js","sources":["../../../../src/react-aria/react-aria/spinbutton/useSpinButton.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 { announce, clearAnnouncer } from '../live-announcer';\nimport { AriaButtonProps } from '../../react-types/button';\nimport { DOMAttributes, InputBase, RangeInputBase, Validation, ValueBase } from '../../react-types/shared';\n// @ts-ignore\nimport intlMessages from './intl';\nimport { useEffect, useRef } from 'react';\nimport { useEffectEvent, useGlobalListeners } from '../utils';\n\nimport { useMessageFormatter } from '../i18n';\n\nexport interface SpinButtonProps extends InputBase, Validation<number>, ValueBase<number>, RangeInputBase<number> {\n textValue?: string;\n onIncrement?: () => void;\n onIncrementPage?: () => void;\n onDecrement?: () => void;\n onDecrementPage?: () => void;\n onDecrementToMin?: () => void;\n onIncrementToMax?: () => void;\n}\n\nexport interface SpinbuttonAria {\n spinButtonProps: DOMAttributes;\n incrementButtonProps: AriaButtonProps;\n decrementButtonProps: AriaButtonProps;\n}\n\nexport function useSpinButton(props: SpinButtonProps): SpinbuttonAria {\n const _async = useRef<number>();\n let {\n value,\n textValue,\n minValue,\n maxValue,\n isDisabled,\n isReadOnly,\n isRequired,\n onIncrement,\n onIncrementPage,\n onDecrement,\n onDecrementPage,\n onDecrementToMin,\n onIncrementToMax,\n } = props;\n const format = useMessageFormatter(intlMessages);\n\n const clearAsync = () => clearTimeout(_async.current);\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => clearAsync();\n }, []);\n\n let onKeyDown = (e) => {\n if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || isReadOnly) {\n return;\n }\n\n switch (e.key) {\n case 'PageUp':\n if (onIncrementPage) {\n e.preventDefault();\n onIncrementPage?.();\n break;\n }\n // fallthrough!\n case 'ArrowUp':\n case 'Up':\n if (onIncrement) {\n e.preventDefault();\n onIncrement?.();\n }\n break;\n case 'PageDown':\n if (onDecrementPage) {\n e.preventDefault();\n onDecrementPage?.();\n break;\n }\n // fallthrough\n case 'ArrowDown':\n case 'Down':\n if (onDecrement) {\n e.preventDefault();\n onDecrement?.();\n }\n break;\n case 'Home':\n if (onDecrementToMin) {\n e.preventDefault();\n onDecrementToMin?.();\n }\n break;\n case 'End':\n if (onIncrementToMax) {\n e.preventDefault();\n onIncrementToMax?.();\n }\n break;\n }\n };\n\n let isFocused = useRef(false);\n let onFocus = () => {\n isFocused.current = true;\n };\n\n let onBlur = () => {\n isFocused.current = false;\n };\n\n // Replace Unicode hyphen-minus (U+002D) with minus sign (U+2212).\n // This ensures that macOS VoiceOver announces it as \"minus\" even with other characters between the minus sign\n // and the number (e.g. currency symbol). Otherwise it announces nothing because it assumes the character is a hyphen.\n // In addition, replace the empty string with the word \"Empty\" so that iOS VoiceOver does not read \"50%\" for an empty field.\n let ariaTextValue = textValue === '' ? format('Empty') : (textValue || `${value}`).replace('-', '\\u2212');\n\n useEffect(() => {\n if (isFocused.current) {\n clearAnnouncer('assertive');\n announce(ariaTextValue, 'assertive');\n }\n }, [ariaTextValue]);\n\n const onIncrementPressStart = useEffectEvent((initialStepDelay: number) => {\n clearAsync();\n onIncrement?.();\n // Start spinning after initial delay\n _async.current = window.setTimeout(() => {\n if (maxValue === undefined || isNaN(maxValue) || value === undefined || isNaN(value) || value < maxValue) {\n onIncrementPressStart(60);\n }\n }, initialStepDelay);\n });\n\n const onDecrementPressStart = useEffectEvent((initialStepDelay: number) => {\n clearAsync();\n onDecrement?.();\n // Start spinning after initial delay\n _async.current = window.setTimeout(() => {\n if (minValue === undefined || isNaN(minValue) || value === undefined || isNaN(value) || value > minValue) {\n onDecrementPressStart(60);\n }\n }, initialStepDelay);\n });\n\n let cancelContextMenu = (e) => {\n e.preventDefault();\n };\n\n let { addGlobalListener, removeAllGlobalListeners } = useGlobalListeners();\n\n return {\n spinButtonProps: {\n role: 'spinbutton',\n 'aria-valuenow': value !== undefined && !isNaN(value) ? value : undefined,\n 'aria-valuetext': ariaTextValue,\n 'aria-valuemin': minValue,\n 'aria-valuemax': maxValue,\n 'aria-disabled': isDisabled || undefined,\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n onKeyDown,\n onFocus,\n onBlur,\n },\n incrementButtonProps: {\n onPressStart: () => {\n onIncrementPressStart(400);\n addGlobalListener(window, 'contextmenu', cancelContextMenu);\n },\n onPressEnd: () => {\n clearAsync();\n removeAllGlobalListeners();\n },\n onFocus,\n onBlur,\n },\n decrementButtonProps: {\n onPressStart: () => {\n onDecrementPressStart(400);\n addGlobalListener(window, 'contextmenu', cancelContextMenu);\n },\n onPressEnd: () => {\n clearAsync();\n removeAllGlobalListeners();\n },\n onFocus,\n onBlur,\n },\n };\n}\n"],"names":["useSpinButton","props","_async","useRef","value","textValue","minValue","maxValue","isDisabled","isReadOnly","isRequired","onIncrement","onIncrementPage","onDecrement","onDecrementPage","onDecrementToMin","onIncrementToMax","format","useMessageFormatter","intlMessages","clearAsync","clearTimeout","current","useEffect","onKeyDown","e","ctrlKey","metaKey","shiftKey","altKey","key","preventDefault","isFocused","onFocus","onBlur","ariaTextValue","replace","clearAnnouncer","announce","onIncrementPressStart","useEffectEvent","initialStepDelay","window","setTimeout","undefined","isNaN","onDecrementPressStart","cancelContextMenu","addGlobalListener","removeAllGlobalListeners","useGlobalListeners","spinButtonProps","role","incrementButtonProps","onPressStart","onPressEnd","decrementButtonProps"],"mappings":";;;;;;;AAAA;AAwCO,SAASA,aAAaA,CAACC,KAAsB,EAAkB;AACpE,EAAA,MAAMC,MAAM,GAAGC,MAAM,EAAU,CAAA;EAC/B,IAAI;IACFC,KAAK;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C,MAAAA,MAAAA;KACD;AACDsB,IAAAA,oBAAoB,EAAE;MACpBF,YAAY,EAAEA,MAAM;QAClBR,qBAAqB,CAAC,GAAG,CAAC,CAAA;AAC1BE,QAAAA,iBAAiB,CAACN,MAAM,EAAE,aAAa,EAAEK,iBAAiB,CAAC,CAAA;OAC5D;MACDQ,UAAU,EAAEA,MAAM;AAChBnC,QAAAA,UAAU,EAAE,CAAA;AACZ6B,QAAAA,wBAAwB,EAAE,CAAA;OAC3B;MACDhB,OAAO;AACPC,MAAAA,MAAAA;AACF,KAAA;GACD,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
interface SSRProviderProps {
|
|
4
|
+
/** Your application here. */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* When using SSR with React Aria in React 16 or 17, applications must be wrapped in an SSRProvider.
|
|
9
|
+
* This ensures that auto generated ids are consistent between the client and server.
|
|
10
|
+
*/
|
|
11
|
+
declare function SSRProvider(props: SSRProviderProps): JSX.Element;
|
|
12
|
+
declare function useModernSSRSafeId(defaultId?: string): string;
|
|
13
|
+
/** @private */
|
|
14
|
+
declare const useSSRSafeId: typeof useModernSSRSafeId;
|
|
15
|
+
/**
|
|
16
|
+
* Returns whether the component is currently being server side rendered or
|
|
17
|
+
* hydrated on the client. Can be used to delay browser-specific rendering
|
|
18
|
+
* until after hydration.
|
|
19
|
+
*/
|
|
20
|
+
declare function useIsSSR(): boolean;
|
|
21
|
+
|
|
22
|
+
export { SSRProvider, SSRProviderProps, useIsSSR, useSSRSafeId };
|