@redsift/design-system 11.5.0 → 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,196 @@
|
|
|
1
|
+
import { objectSpread2 as _objectSpread2 } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
3
|
+
import { snapValueToStep, clamp } from '../utils/number.js';
|
|
4
|
+
import { useControlledState } from '../utils/useControlledState.js';
|
|
5
|
+
import { NumberFormatter } from '../../internationalized/number/NumberFormatter.js';
|
|
6
|
+
import { NumberParser } from '../../internationalized/number/NumberParser.js';
|
|
7
|
+
import { useFormValidationState } from '../form/useFormValidationState.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Provides state management for a number field component. Number fields allow users to enter a number,
|
|
11
|
+
* and increment or decrement the value using stepper buttons.
|
|
12
|
+
*/
|
|
13
|
+
function useNumberFieldState(props) {
|
|
14
|
+
let {
|
|
15
|
+
minValue,
|
|
16
|
+
maxValue,
|
|
17
|
+
step,
|
|
18
|
+
formatOptions,
|
|
19
|
+
value,
|
|
20
|
+
defaultValue = NaN,
|
|
21
|
+
onChange,
|
|
22
|
+
locale,
|
|
23
|
+
isDisabled,
|
|
24
|
+
isReadOnly
|
|
25
|
+
} = props;
|
|
26
|
+
if (value === null) {
|
|
27
|
+
value = NaN;
|
|
28
|
+
}
|
|
29
|
+
if (value !== undefined && !isNaN(value)) {
|
|
30
|
+
if (step !== undefined && !isNaN(step)) {
|
|
31
|
+
value = snapValueToStep(value, minValue, maxValue, step);
|
|
32
|
+
} else {
|
|
33
|
+
value = clamp(value, minValue, maxValue);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!isNaN(defaultValue)) {
|
|
37
|
+
if (step !== undefined && !isNaN(step)) {
|
|
38
|
+
defaultValue = snapValueToStep(defaultValue, minValue, maxValue, step);
|
|
39
|
+
} else {
|
|
40
|
+
defaultValue = clamp(defaultValue, minValue, maxValue);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
let [numberValue, setNumberValue] = useControlledState(value, isNaN(defaultValue) ? NaN : defaultValue, onChange);
|
|
44
|
+
let [inputValue, setInputValue] = useState(() => isNaN(numberValue) ? '' : new NumberFormatter(locale, formatOptions).format(numberValue));
|
|
45
|
+
let numberParser = useMemo(() => new NumberParser(locale, formatOptions), [locale, formatOptions]);
|
|
46
|
+
let numberingSystem = useMemo(() => numberParser.getNumberingSystem(inputValue), [numberParser, inputValue]);
|
|
47
|
+
let formatter = useMemo(() => new NumberFormatter(locale, _objectSpread2(_objectSpread2({}, formatOptions), {}, {
|
|
48
|
+
numberingSystem
|
|
49
|
+
})), [locale, formatOptions, numberingSystem]);
|
|
50
|
+
let intlOptions = useMemo(() => formatter.resolvedOptions(), [formatter]);
|
|
51
|
+
let format = useCallback(value => isNaN(value) || value === null ? '' : formatter.format(value), [formatter]);
|
|
52
|
+
let validation = useFormValidationState(_objectSpread2(_objectSpread2({}, props), {}, {
|
|
53
|
+
value: numberValue
|
|
54
|
+
}));
|
|
55
|
+
let clampStep = step !== undefined && !isNaN(step) ? step : 1;
|
|
56
|
+
if (intlOptions.style === 'percent' && (step === undefined || isNaN(step))) {
|
|
57
|
+
clampStep = 0.01;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Update the input value when the number value or format options change. This is done
|
|
61
|
+
// in a useEffect so that the controlled behavior is correct and we only update the
|
|
62
|
+
// textfield after prop changes.
|
|
63
|
+
let [prevValue, setPrevValue] = useState(numberValue);
|
|
64
|
+
let [prevLocale, setPrevLocale] = useState(locale);
|
|
65
|
+
let [prevFormatOptions, setPrevFormatOptions] = useState(formatOptions);
|
|
66
|
+
if (!Object.is(numberValue, prevValue) || locale !== prevLocale || formatOptions !== prevFormatOptions) {
|
|
67
|
+
setInputValue(format(numberValue));
|
|
68
|
+
setPrevValue(numberValue);
|
|
69
|
+
setPrevLocale(locale);
|
|
70
|
+
setPrevFormatOptions(formatOptions);
|
|
71
|
+
}
|
|
72
|
+
let parsedValue = useMemo(() => numberParser.parse(inputValue), [numberParser, inputValue]);
|
|
73
|
+
let commit = () => {
|
|
74
|
+
// Set to empty state if input value is empty
|
|
75
|
+
if (!inputValue.length) {
|
|
76
|
+
setNumberValue(NaN);
|
|
77
|
+
setInputValue(value === undefined ? '' : format(numberValue));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// if it failed to parse, then reset input to formatted version of current number
|
|
82
|
+
if (isNaN(parsedValue)) {
|
|
83
|
+
setInputValue(format(numberValue));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Clamp to min and max, round to the nearest step, and round to specified number of digits
|
|
88
|
+
let clampedValue;
|
|
89
|
+
if (step === undefined || isNaN(step)) {
|
|
90
|
+
clampedValue = clamp(parsedValue, minValue, maxValue);
|
|
91
|
+
} else {
|
|
92
|
+
clampedValue = snapValueToStep(parsedValue, minValue, maxValue, step);
|
|
93
|
+
}
|
|
94
|
+
clampedValue = numberParser.parse(format(clampedValue));
|
|
95
|
+
setNumberValue(clampedValue);
|
|
96
|
+
|
|
97
|
+
// in a controlled state, the numberValue won't change, so we won't go back to our old input without help
|
|
98
|
+
setInputValue(format(value === undefined ? clampedValue : numberValue));
|
|
99
|
+
};
|
|
100
|
+
let safeNextStep = function (operation) {
|
|
101
|
+
let minMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
102
|
+
let prev = parsedValue;
|
|
103
|
+
if (isNaN(prev)) {
|
|
104
|
+
// if the input is empty, start from the min/max value when incrementing/decrementing,
|
|
105
|
+
// or zero if there is no min/max value defined.
|
|
106
|
+
let newValue = isNaN(minMax) ? 0 : minMax;
|
|
107
|
+
return snapValueToStep(newValue, minValue, maxValue, clampStep);
|
|
108
|
+
} else {
|
|
109
|
+
// otherwise, first snap the current value to the nearest step. if it moves in the direction
|
|
110
|
+
// we're going, use that value, otherwise add the step and snap that value.
|
|
111
|
+
let newValue = snapValueToStep(prev, minValue, maxValue, clampStep);
|
|
112
|
+
if (operation === '+' && newValue > prev || operation === '-' && newValue < prev) {
|
|
113
|
+
return newValue;
|
|
114
|
+
}
|
|
115
|
+
return snapValueToStep(handleDecimalOperation(operation, prev, clampStep), minValue, maxValue, clampStep);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
let increment = () => {
|
|
119
|
+
let newValue = safeNextStep('+', minValue);
|
|
120
|
+
|
|
121
|
+
// if we've arrived at the same value that was previously in the state, the
|
|
122
|
+
// input value should be updated to match
|
|
123
|
+
// ex type 4, press increment, highlight the number in the input, type 4 again, press increment
|
|
124
|
+
// you'd be at 5, then incrementing to 5 again, so no re-render would happen and 4 would be left in the input
|
|
125
|
+
if (newValue === numberValue) {
|
|
126
|
+
setInputValue(format(newValue));
|
|
127
|
+
}
|
|
128
|
+
setNumberValue(newValue);
|
|
129
|
+
validation.commitValidation();
|
|
130
|
+
};
|
|
131
|
+
let decrement = () => {
|
|
132
|
+
let newValue = safeNextStep('-', maxValue);
|
|
133
|
+
if (newValue === numberValue) {
|
|
134
|
+
setInputValue(format(newValue));
|
|
135
|
+
}
|
|
136
|
+
setNumberValue(newValue);
|
|
137
|
+
validation.commitValidation();
|
|
138
|
+
};
|
|
139
|
+
let incrementToMax = () => {
|
|
140
|
+
if (maxValue != null) {
|
|
141
|
+
setNumberValue(snapValueToStep(maxValue, minValue, maxValue, clampStep));
|
|
142
|
+
validation.commitValidation();
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
let decrementToMin = () => {
|
|
146
|
+
if (minValue != null) {
|
|
147
|
+
setNumberValue(minValue);
|
|
148
|
+
validation.commitValidation();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
let canIncrement = useMemo(() => !isDisabled && !isReadOnly && (isNaN(parsedValue) || maxValue === undefined || isNaN(maxValue) || snapValueToStep(parsedValue, minValue, maxValue, clampStep) > parsedValue || handleDecimalOperation('+', parsedValue, clampStep) <= maxValue), [isDisabled, isReadOnly, minValue, maxValue, clampStep, parsedValue]);
|
|
152
|
+
let canDecrement = useMemo(() => !isDisabled && !isReadOnly && (isNaN(parsedValue) || minValue === undefined || isNaN(minValue) || snapValueToStep(parsedValue, minValue, maxValue, clampStep) < parsedValue || handleDecimalOperation('-', parsedValue, clampStep) >= minValue), [isDisabled, isReadOnly, minValue, maxValue, clampStep, parsedValue]);
|
|
153
|
+
let validate = value => numberParser.isValidPartialNumber(value, minValue, maxValue);
|
|
154
|
+
return _objectSpread2(_objectSpread2({}, validation), {}, {
|
|
155
|
+
validate,
|
|
156
|
+
increment,
|
|
157
|
+
incrementToMax,
|
|
158
|
+
decrement,
|
|
159
|
+
decrementToMin,
|
|
160
|
+
canIncrement,
|
|
161
|
+
canDecrement,
|
|
162
|
+
minValue,
|
|
163
|
+
maxValue,
|
|
164
|
+
numberValue: parsedValue,
|
|
165
|
+
setNumberValue,
|
|
166
|
+
setInputValue,
|
|
167
|
+
inputValue,
|
|
168
|
+
commit
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function handleDecimalOperation(operator, value1, value2) {
|
|
172
|
+
let result = operator === '+' ? value1 + value2 : value1 - value2;
|
|
173
|
+
|
|
174
|
+
// Check if we have decimals
|
|
175
|
+
if (value1 % 1 !== 0 || value2 % 1 !== 0) {
|
|
176
|
+
const value1Decimal = value1.toString().split('.');
|
|
177
|
+
const value2Decimal = value2.toString().split('.');
|
|
178
|
+
const value1DecimalLength = value1Decimal[1] && value1Decimal[1].length || 0;
|
|
179
|
+
const value2DecimalLength = value2Decimal[1] && value2Decimal[1].length || 0;
|
|
180
|
+
const multiplier = Math.pow(10, Math.max(value1DecimalLength, value2DecimalLength));
|
|
181
|
+
|
|
182
|
+
// Transform the decimals to integers based on the precision
|
|
183
|
+
value1 = Math.round(value1 * multiplier);
|
|
184
|
+
value2 = Math.round(value2 * multiplier);
|
|
185
|
+
|
|
186
|
+
// Perform the operation on integers values to make sure we don't get a fancy decimal value
|
|
187
|
+
result = operator === '+' ? value1 + value2 : value1 - value2;
|
|
188
|
+
|
|
189
|
+
// Transform the integer result back to decimal
|
|
190
|
+
result /= multiplier;
|
|
191
|
+
}
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export { useNumberFieldState };
|
|
196
|
+
//# sourceMappingURL=useNumberFieldState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useNumberFieldState.js","sources":["../../../../src/react-aria/react-stately/numberfield/useNumberFieldState.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 { clamp, snapValueToStep, useControlledState } from '../utils';\nimport { FormValidationState, useFormValidationState } from '../form';\nimport { NumberFieldProps } from '../../react-types/numberfield';\nimport { NumberFormatter, NumberParser } from '../../internationalized/number';\nimport { useCallback, useMemo, useState } from 'react';\n\nexport interface NumberFieldState extends FormValidationState {\n /**\n * The current text value of the input. Updated as the user types,\n * and formatted according to `formatOptions` on blur.\n */\n inputValue: string;\n /**\n * The currently parsed number value, or NaN if a valid number could not be parsed.\n * Updated based on the `inputValue` as the user types.\n */\n numberValue: number;\n /** The minimum value of the number field. */\n minValue?: number;\n /** The maximum value of the number field. */\n maxValue?: number;\n /** Whether the current value can be incremented according to the maximum value and step. */\n canIncrement: boolean;\n /** Whether the current value can be decremented according to the minimum value and step. */\n canDecrement: boolean;\n /**\n * Validates a user input string according to the current locale and format options.\n * Values can be partially entered, and may be valid even if they cannot currently be parsed to a number.\n * Can be used to implement validation as a user types.\n */\n validate(value: string): boolean;\n /** Sets the current text value of the input. */\n setInputValue(val: string): void;\n /** Sets the number value. */\n setNumberValue(val: number): void;\n /**\n * Commits the current input value. The value is parsed to a number, clamped according\n * to the minimum and maximum values of the field, and snapped to the nearest step value.\n * This will fire the `onChange` prop with the new value, and if uncontrolled, update the `numberValue`.\n * Typically this is called when the field is blurred.\n */\n commit(): void;\n /** Increments the current input value to the next step boundary, and fires `onChange`. */\n increment(): void;\n /** Decrements the current input value to the next step boundary, and fires `onChange`. */\n decrement(): void;\n /** Sets the current value to the `maxValue` if any, and fires `onChange`. */\n incrementToMax(): void;\n /** Sets the current value to the `minValue` if any, and fires `onChange`. */\n decrementToMin(): void;\n}\n\nexport interface NumberFieldStateOptions extends NumberFieldProps {\n /**\n * The locale that should be used for parsing.\n * @default 'en-US'\n */\n locale: string;\n}\n\n/**\n * Provides state management for a number field component. Number fields allow users to enter a number,\n * and increment or decrement the value using stepper buttons.\n */\nexport function useNumberFieldState(props: NumberFieldStateOptions): NumberFieldState {\n let {\n minValue,\n maxValue,\n step,\n formatOptions,\n value,\n defaultValue = NaN,\n onChange,\n locale,\n isDisabled,\n isReadOnly,\n } = props;\n\n if (value === null) {\n value = NaN;\n }\n\n if (value !== undefined && !isNaN(value)) {\n if (step !== undefined && !isNaN(step)) {\n value = snapValueToStep(value, minValue, maxValue, step);\n } else {\n value = clamp(value, minValue, maxValue);\n }\n }\n\n if (!isNaN(defaultValue)) {\n if (step !== undefined && !isNaN(step)) {\n defaultValue = snapValueToStep(defaultValue, minValue, maxValue, step);\n } else {\n defaultValue = clamp(defaultValue, minValue, maxValue);\n }\n }\n\n let [numberValue, setNumberValue] = useControlledState<number>(\n value,\n isNaN(defaultValue) ? NaN : defaultValue,\n onChange\n );\n let [inputValue, setInputValue] = useState(() =>\n isNaN(numberValue) ? '' : new NumberFormatter(locale, formatOptions).format(numberValue)\n );\n\n let numberParser = useMemo(() => new NumberParser(locale, formatOptions), [locale, formatOptions]);\n let numberingSystem = useMemo(() => numberParser.getNumberingSystem(inputValue), [numberParser, inputValue]);\n let formatter = useMemo(\n () => new NumberFormatter(locale, { ...formatOptions, numberingSystem }),\n [locale, formatOptions, numberingSystem]\n );\n let intlOptions = useMemo(() => formatter.resolvedOptions(), [formatter]);\n let format = useCallback(\n (value: number) => (isNaN(value) || value === null ? '' : formatter.format(value)),\n [formatter]\n );\n\n let validation = useFormValidationState({\n ...props,\n value: numberValue,\n });\n\n let clampStep = step !== undefined && !isNaN(step) ? step : 1;\n if (intlOptions.style === 'percent' && (step === undefined || isNaN(step))) {\n clampStep = 0.01;\n }\n\n // Update the input value when the number value or format options change. This is done\n // in a useEffect so that the controlled behavior is correct and we only update the\n // textfield after prop changes.\n let [prevValue, setPrevValue] = useState(numberValue);\n let [prevLocale, setPrevLocale] = useState(locale);\n let [prevFormatOptions, setPrevFormatOptions] = useState(formatOptions);\n if (!Object.is(numberValue, prevValue) || locale !== prevLocale || formatOptions !== prevFormatOptions) {\n setInputValue(format(numberValue));\n setPrevValue(numberValue);\n setPrevLocale(locale);\n setPrevFormatOptions(formatOptions);\n }\n\n let parsedValue = useMemo(() => numberParser.parse(inputValue), [numberParser, inputValue]);\n let commit = () => {\n // Set to empty state if input value is empty\n if (!inputValue.length) {\n setNumberValue(NaN);\n setInputValue(value === undefined ? '' : format(numberValue));\n return;\n }\n\n // if it failed to parse, then reset input to formatted version of current number\n if (isNaN(parsedValue)) {\n setInputValue(format(numberValue));\n return;\n }\n\n // Clamp to min and max, round to the nearest step, and round to specified number of digits\n let clampedValue: number;\n if (step === undefined || isNaN(step)) {\n clampedValue = clamp(parsedValue, minValue, maxValue);\n } else {\n clampedValue = snapValueToStep(parsedValue, minValue, maxValue, step);\n }\n\n clampedValue = numberParser.parse(format(clampedValue));\n setNumberValue(clampedValue);\n\n // in a controlled state, the numberValue won't change, so we won't go back to our old input without help\n setInputValue(format(value === undefined ? clampedValue : numberValue));\n };\n\n let safeNextStep = (operation: '+' | '-', minMax: number = 0) => {\n let prev = parsedValue;\n\n if (isNaN(prev)) {\n // if the input is empty, start from the min/max value when incrementing/decrementing,\n // or zero if there is no min/max value defined.\n let newValue = isNaN(minMax) ? 0 : minMax;\n return snapValueToStep(newValue, minValue, maxValue, clampStep);\n } else {\n // otherwise, first snap the current value to the nearest step. if it moves in the direction\n // we're going, use that value, otherwise add the step and snap that value.\n let newValue = snapValueToStep(prev, minValue, maxValue, clampStep);\n if ((operation === '+' && newValue > prev) || (operation === '-' && newValue < prev)) {\n return newValue;\n }\n\n return snapValueToStep(handleDecimalOperation(operation, prev, clampStep), minValue, maxValue, clampStep);\n }\n };\n\n let increment = () => {\n let newValue = safeNextStep('+', minValue);\n\n // if we've arrived at the same value that was previously in the state, the\n // input value should be updated to match\n // ex type 4, press increment, highlight the number in the input, type 4 again, press increment\n // you'd be at 5, then incrementing to 5 again, so no re-render would happen and 4 would be left in the input\n if (newValue === numberValue) {\n setInputValue(format(newValue));\n }\n\n setNumberValue(newValue);\n validation.commitValidation();\n };\n\n let decrement = () => {\n let newValue = safeNextStep('-', maxValue);\n\n if (newValue === numberValue) {\n setInputValue(format(newValue));\n }\n\n setNumberValue(newValue);\n validation.commitValidation();\n };\n\n let incrementToMax = () => {\n if (maxValue != null) {\n setNumberValue(snapValueToStep(maxValue, minValue, maxValue, clampStep));\n validation.commitValidation();\n }\n };\n\n let decrementToMin = () => {\n if (minValue != null) {\n setNumberValue(minValue);\n validation.commitValidation();\n }\n };\n\n let canIncrement = useMemo(\n () =>\n !isDisabled &&\n !isReadOnly &&\n (isNaN(parsedValue) ||\n maxValue === undefined ||\n isNaN(maxValue) ||\n snapValueToStep(parsedValue, minValue, maxValue, clampStep) > parsedValue ||\n handleDecimalOperation('+', parsedValue, clampStep) <= maxValue),\n [isDisabled, isReadOnly, minValue, maxValue, clampStep, parsedValue]\n );\n\n let canDecrement = useMemo(\n () =>\n !isDisabled &&\n !isReadOnly &&\n (isNaN(parsedValue) ||\n minValue === undefined ||\n isNaN(minValue) ||\n snapValueToStep(parsedValue, minValue, maxValue, clampStep) < parsedValue ||\n handleDecimalOperation('-', parsedValue, clampStep) >= minValue),\n [isDisabled, isReadOnly, minValue, maxValue, clampStep, parsedValue]\n );\n\n let validate = (value: string) => numberParser.isValidPartialNumber(value, minValue, maxValue);\n\n return {\n ...validation,\n validate,\n increment,\n incrementToMax,\n decrement,\n decrementToMin,\n canIncrement,\n canDecrement,\n minValue,\n maxValue,\n numberValue: parsedValue,\n setNumberValue,\n setInputValue,\n inputValue,\n commit,\n };\n}\n\nfunction handleDecimalOperation(operator: '-' | '+', value1: number, value2: number): number {\n let result = operator === '+' ? value1 + value2 : value1 - value2;\n\n // Check if we have decimals\n if (value1 % 1 !== 0 || value2 % 1 !== 0) {\n const value1Decimal = value1.toString().split('.');\n const value2Decimal = value2.toString().split('.');\n const value1DecimalLength = (value1Decimal[1] && value1Decimal[1].length) || 0;\n const value2DecimalLength = (value2Decimal[1] && value2Decimal[1].length) || 0;\n const multiplier = Math.pow(10, Math.max(value1DecimalLength, value2DecimalLength));\n\n // Transform the decimals to integers based on the precision\n value1 = Math.round(value1 * multiplier);\n value2 = Math.round(value2 * multiplier);\n\n // Perform the operation on integers values to make sure we don't get a fancy decimal value\n result = operator === '+' ? value1 + value2 : value1 - value2;\n\n // Transform the integer result back to decimal\n result /= multiplier;\n }\n\n return result;\n}\n"],"names":["useNumberFieldState","props","minValue","maxValue","step","formatOptions","value","defaultValue","NaN","onChange","locale","isDisabled","isReadOnly","undefined","isNaN","snapValueToStep","clamp","numberValue","setNumberValue","useControlledState","inputValue","setInputValue","useState","NumberFormatter","format","numberParser","useMemo","NumberParser","numberingSystem","getNumberingSystem","formatter","_objectSpread","intlOptions","resolvedOptions","useCallback","validation","useFormValidationState","clampStep","style","prevValue","setPrevValue","prevLocale","setPrevLocale","prevFormatOptions","setPrevFormatOptions","Object","is","parsedValue","parse","commit","length","clampedValue","safeNextStep","operation","minMax","arguments","prev","newValue","handleDecimalOperation","increment","commitValidation","decrement","incrementToMax","decrementToMin","canIncrement","canDecrement","validate","isValidPartialNumber","operator","value1","value2","result","value1Decimal","toString","split","value2Decimal","value1DecimalLength","value2DecimalLength","multiplier","Math","pow","max","round"],"mappings":";;;;;;;;AA0EA;AACA;AACA;AACA;AACO,SAASA,mBAAmBA,CAACC,KAA8B,EAAoB;EACpF,IAAI;IACFC,QAAQ;IACRC,QAAQ;IACRC,IAAI;IACJC,aAAa;IACbC,KAAK;AACLC,IAAAA,YAAY,GAAGC,GAAG;IAClBC,QAAQ;IACRC,MAAM;IACNC,UAAU;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,UAAU,CAAC,CAAA;;AAExC;IACAP,MAAM,GAAGH,QAAQ,KAAK,GAAG,GAAGC,MAAM,GAAGC,MAAM,GAAGD,MAAM,GAAGC,MAAM,CAAA;;AAE7D;AACAC,IAAAA,MAAM,IAAIO,UAAU,CAAA;AACtB,GAAA;AAEA,EAAA,OAAOP,MAAM,CAAA;AACf;;;;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
/**
|
|
16
|
+
* Takes a value and forces it to the closest min/max if it's outside. Also forces it to the closest valid step.
|
|
17
|
+
*/
|
|
18
|
+
function clamp(value) {
|
|
19
|
+
let min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -Infinity;
|
|
20
|
+
let max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
|
|
21
|
+
let newValue = Math.min(Math.max(value, min), max);
|
|
22
|
+
return newValue;
|
|
23
|
+
}
|
|
24
|
+
function roundToStepPrecision(value, step) {
|
|
25
|
+
let roundedValue = value;
|
|
26
|
+
let stepString = step.toString();
|
|
27
|
+
let pointIndex = stepString.indexOf('.');
|
|
28
|
+
let precision = pointIndex >= 0 ? stepString.length - pointIndex : 0;
|
|
29
|
+
if (precision > 0) {
|
|
30
|
+
let pow = Math.pow(10, precision);
|
|
31
|
+
roundedValue = Math.round(roundedValue * pow) / pow;
|
|
32
|
+
}
|
|
33
|
+
return roundedValue;
|
|
34
|
+
}
|
|
35
|
+
function snapValueToStep(value, min, max, step) {
|
|
36
|
+
min = Number(min);
|
|
37
|
+
max = Number(max);
|
|
38
|
+
let remainder = (value - (isNaN(min) ? 0 : min)) % step;
|
|
39
|
+
let snappedValue = roundToStepPrecision(Math.abs(remainder) * 2 >= step ? value + Math.sign(remainder) * (step - Math.abs(remainder)) : value - remainder, step);
|
|
40
|
+
if (!isNaN(min)) {
|
|
41
|
+
if (snappedValue < min) {
|
|
42
|
+
snappedValue = min;
|
|
43
|
+
} else if (!isNaN(max) && snappedValue > max) {
|
|
44
|
+
snappedValue = min + Math.floor(roundToStepPrecision((max - min) / step, step)) * step;
|
|
45
|
+
}
|
|
46
|
+
} else if (!isNaN(max) && snappedValue > max) {
|
|
47
|
+
snappedValue = Math.floor(roundToStepPrecision(max / step, step)) * step;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// correct floating point behavior by rounding to step precision
|
|
51
|
+
snappedValue = roundToStepPrecision(snappedValue, step);
|
|
52
|
+
return snappedValue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { clamp, roundToStepPrecision, snapValueToStep };
|
|
56
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.js","sources":["../../../../src/react-aria/react-stately/utils/number.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/**\n * Takes a value and forces it to the closest min/max if it's outside. Also forces it to the closest valid step.\n */\nexport function clamp(value: number, min: number = -Infinity, max: number = Infinity): number {\n let newValue = Math.min(Math.max(value, min), max);\n return newValue;\n}\n\nexport function roundToStepPrecision(value: number, step: number) {\n let roundedValue = value;\n let stepString = step.toString();\n let pointIndex = stepString.indexOf('.');\n let precision = pointIndex >= 0 ? stepString.length - pointIndex : 0;\n if (precision > 0) {\n let pow = Math.pow(10, precision);\n roundedValue = Math.round(roundedValue * pow) / pow;\n }\n return roundedValue;\n}\n\nexport function snapValueToStep(value: number, min: number | undefined, max: number | undefined, step: number): number {\n min = Number(min);\n max = Number(max);\n let remainder = (value - (isNaN(min) ? 0 : min)) % step;\n let snappedValue = roundToStepPrecision(\n Math.abs(remainder) * 2 >= step ? value + Math.sign(remainder) * (step - Math.abs(remainder)) : value - remainder,\n step\n );\n\n if (!isNaN(min)) {\n if (snappedValue < min) {\n snappedValue = min;\n } else if (!isNaN(max) && snappedValue > max) {\n snappedValue = min + Math.floor(roundToStepPrecision((max - min) / step, step)) * step;\n }\n } else if (!isNaN(max) && snappedValue > max) {\n snappedValue = Math.floor(roundToStepPrecision(max / step, step)) * step;\n }\n\n // correct floating point behavior by rounding to step precision\n snappedValue = roundToStepPrecision(snappedValue, step);\n\n return snappedValue;\n}\n\n/* Takes a value and rounds off to the number of digits. */\nexport function toFixedNumber(value: number, digits: number, base: number = 10): number {\n const pow = Math.pow(base, digits);\n\n return Math.round(value * pow) / pow;\n}\n"],"names":["clamp","value","min","arguments","length","undefined","Infinity","max","newValue","Math","roundToStepPrecision","step","roundedValue","stepString","toString","pointIndex","indexOf","precision","pow","round","snapValueToStep","Number","remainder","isNaN","snappedValue","abs","sign","floor"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,SAASA,KAAKA,CAACC,KAAa,EAA2D;AAAA,EAAA,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-0,0 +1,68 @@
|
|
|
1
|
+
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable prefer-const */
|
|
4
|
+
function useControlledState(value, defaultValue, onChange) {
|
|
5
|
+
let [stateValue, setStateValue] = useState(value || defaultValue);
|
|
6
|
+
let isControlledRef = useRef(value !== undefined);
|
|
7
|
+
let isControlled = value !== undefined;
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
let wasControlled = isControlledRef.current;
|
|
10
|
+
if (wasControlled !== isControlled) {
|
|
11
|
+
console.warn(`WARN: A component changed from ${wasControlled ? 'controlled' : 'uncontrolled'} to ${isControlled ? 'controlled' : 'uncontrolled'}.`);
|
|
12
|
+
}
|
|
13
|
+
isControlledRef.current = isControlled;
|
|
14
|
+
}, [isControlled]);
|
|
15
|
+
let currentValue = isControlled ? value : stateValue;
|
|
16
|
+
let setValue = useCallback(function (value) {
|
|
17
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
18
|
+
args[_key - 1] = arguments[_key];
|
|
19
|
+
}
|
|
20
|
+
let onChangeCaller = function (value) {
|
|
21
|
+
if (onChange) {
|
|
22
|
+
if (!Object.is(currentValue, value)) {
|
|
23
|
+
for (var _len2 = arguments.length, onChangeArgs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
24
|
+
onChangeArgs[_key2 - 1] = arguments[_key2];
|
|
25
|
+
}
|
|
26
|
+
onChange(value, ...onChangeArgs);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!isControlled) {
|
|
30
|
+
// If uncontrolled, mutate the currentValue local variable so that
|
|
31
|
+
// calling setState multiple times with the same value only emits onChange once.
|
|
32
|
+
// We do not use a ref for this because we specifically _do_ want the value to
|
|
33
|
+
// reset every render, and assigning to a ref in render breaks aborted suspended renders.
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
currentValue = value;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
if (typeof value === 'function') {
|
|
39
|
+
console.warn('We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320');
|
|
40
|
+
// this supports functional updates https://reactjs.org/docs/hooks-reference.html#functional-updates
|
|
41
|
+
// when someone using useControlledState calls setControlledState(myFunc)
|
|
42
|
+
// this will call our useState setState with a function as well which invokes myFunc and calls onChange with the value from myFunc
|
|
43
|
+
// if we're in an uncontrolled state, then we also return the value of myFunc which to setState looks as though it was just called with myFunc from the beginning
|
|
44
|
+
// otherwise we just return the controlled value, which won't cause a rerender because React knows to bail out when the value is the same
|
|
45
|
+
let updateFunction = function (oldValue) {
|
|
46
|
+
for (var _len3 = arguments.length, functionArgs = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
47
|
+
functionArgs[_key3 - 1] = arguments[_key3];
|
|
48
|
+
}
|
|
49
|
+
let interceptedValue = value(isControlled ? currentValue : oldValue, ...functionArgs);
|
|
50
|
+
onChangeCaller(interceptedValue, ...args);
|
|
51
|
+
if (!isControlled) {
|
|
52
|
+
return interceptedValue;
|
|
53
|
+
}
|
|
54
|
+
return oldValue;
|
|
55
|
+
};
|
|
56
|
+
setStateValue(updateFunction);
|
|
57
|
+
} else {
|
|
58
|
+
if (!isControlled) {
|
|
59
|
+
setStateValue(value);
|
|
60
|
+
}
|
|
61
|
+
onChangeCaller(value, ...args);
|
|
62
|
+
}
|
|
63
|
+
}, [isControlled, currentValue, onChange]);
|
|
64
|
+
return [currentValue, setValue];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { useControlledState };
|
|
68
|
+
//# sourceMappingURL=useControlledState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useControlledState.js","sources":["../../../../src/react-aria/react-stately/utils/useControlledState.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, useEffect, useRef, useState } from 'react';\n\nexport function useControlledState<T, C = T>(\n value: Exclude<T, undefined>,\n defaultValue: Exclude<T, undefined> | undefined,\n onChange?: (v: C, ...args: any[]) => void\n): [T, (value: T) => void];\nexport function useControlledState<T, C = T>(\n value: Exclude<T, undefined> | undefined,\n defaultValue: Exclude<T, undefined>,\n onChange?: (v: C, ...args: any[]) => void\n): [T, (value: T) => void];\nexport function useControlledState<T, C = T>(\n value: T,\n defaultValue: T,\n onChange?: (v: C, ...args: any[]) => void\n): [T, (value: T) => void] {\n let [stateValue, setStateValue] = useState(value || defaultValue);\n\n let isControlledRef = useRef(value !== undefined);\n let isControlled = value !== undefined;\n useEffect(() => {\n let wasControlled = isControlledRef.current;\n if (wasControlled !== isControlled) {\n console.warn(\n `WARN: A component changed from ${wasControlled ? 'controlled' : 'uncontrolled'} to ${\n isControlled ? 'controlled' : 'uncontrolled'\n }.`\n );\n }\n isControlledRef.current = isControlled;\n }, [isControlled]);\n\n let currentValue = isControlled ? value : stateValue;\n let setValue = useCallback(\n (value, ...args) => {\n let onChangeCaller = (value, ...onChangeArgs) => {\n if (onChange) {\n if (!Object.is(currentValue, value)) {\n onChange(value, ...onChangeArgs);\n }\n }\n if (!isControlled) {\n // If uncontrolled, mutate the currentValue local variable so that\n // calling setState multiple times with the same value only emits onChange once.\n // We do not use a ref for this because we specifically _do_ want the value to\n // reset every render, and assigning to a ref in render breaks aborted suspended renders.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n currentValue = value;\n }\n };\n\n if (typeof value === 'function') {\n console.warn(\n 'We can not support a function callback. See Github Issues for details https://github.com/adobe/react-spectrum/issues/2320'\n );\n // this supports functional updates https://reactjs.org/docs/hooks-reference.html#functional-updates\n // when someone using useControlledState calls setControlledState(myFunc)\n // this will call our useState setState with a function as well which invokes myFunc and calls onChange with the value from myFunc\n // if we're in an uncontrolled state, then we also return the value of myFunc which to setState looks as though it was just called with myFunc from the beginning\n // otherwise we just return the controlled value, which won't cause a rerender because React knows to bail out when the value is the same\n let updateFunction = (oldValue, ...functionArgs) => {\n let interceptedValue = value(isControlled ? currentValue : oldValue, ...functionArgs);\n onChangeCaller(interceptedValue, ...args);\n if (!isControlled) {\n return interceptedValue;\n }\n return oldValue;\n };\n setStateValue(updateFunction);\n } else {\n if (!isControlled) {\n setStateValue(value);\n }\n onChangeCaller(value, ...args);\n }\n },\n [isControlled, currentValue, onChange]\n );\n\n return [currentValue, setValue];\n}\n"],"names":["useControlledState","value","defaultValue","onChange","stateValue","setStateValue","useState","isControlledRef","useRef","undefined","isControlled","useEffect","wasControlled","current","console","warn","currentValue","setValue","useCallback","_len","arguments","length","args","Array","_key","onChangeCaller","Object","is","_len2","onChangeArgs","_key2","updateFunction","oldValue","_len3","functionArgs","_key3","interceptedValue"],"mappings":";;AAAA;AA0BO,SAASA,kBAAkBA,CAChCC,KAAQ,EACRC,YAAe,EACfC,QAAyC,EAChB;EACzB,IAAI,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGC,QAAQ,CAACL,KAAK,IAAIC,YAAY,CAAC,CAAA;AAEjE,EAAA,IAAIK,eAAe,GAAGC,MAAM,CAACP,KAAK,KAAKQ,SAAS,CAAC,CAAA;AACjD,EAAA,IAAIC,YAAY,GAAGT,KAAK,KAAKQ,SAAS,CAAA;AACtCE,EAAAA,SAAS,CAAC,MAAM;AACd,IAAA,IAAIC,aAAa,GAAGL,eAAe,CAACM,OAAO,CAAA;IAC3C,IAAID,aAAa,KAAKF,YAAY,EAAE;AAClCI,MAAAA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AAY,EAAEC,QAAQ,CAAC,CAAA;AACjC;;;;"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ValueOf } from './helpers.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Color palette.
|
|
5
|
+
*/
|
|
6
|
+
declare const Theme: {
|
|
7
|
+
readonly light: "light";
|
|
8
|
+
readonly dark: "dark";
|
|
9
|
+
};
|
|
10
|
+
type Theme = ValueOf<typeof Theme>;
|
|
11
|
+
declare const PrimaryColorPalette: {
|
|
12
|
+
readonly primary: "primary";
|
|
13
|
+
readonly secondary: "secondary";
|
|
14
|
+
readonly error: "error";
|
|
15
|
+
};
|
|
16
|
+
type PrimaryColorPalette = ValueOf<typeof PrimaryColorPalette>;
|
|
17
|
+
declare const SecondaryColorPalette: {
|
|
18
|
+
readonly success: "success";
|
|
19
|
+
readonly warning: "warning";
|
|
20
|
+
readonly info: "info";
|
|
21
|
+
};
|
|
22
|
+
type SecondaryColorPalette = ValueOf<typeof SecondaryColorPalette>;
|
|
23
|
+
declare const ColorPalette: {
|
|
24
|
+
readonly success: "success";
|
|
25
|
+
readonly warning: "warning";
|
|
26
|
+
readonly info: "info";
|
|
27
|
+
readonly primary: "primary";
|
|
28
|
+
readonly secondary: "secondary";
|
|
29
|
+
readonly error: "error";
|
|
30
|
+
};
|
|
31
|
+
type ColorPalette = PrimaryColorPalette & SecondaryColorPalette;
|
|
32
|
+
declare const PrimaryButtonsColorPalette: {
|
|
33
|
+
primary: string;
|
|
34
|
+
secondary: string;
|
|
35
|
+
error: string;
|
|
36
|
+
success: string;
|
|
37
|
+
warning: string;
|
|
38
|
+
grey: string;
|
|
39
|
+
radar: string;
|
|
40
|
+
};
|
|
41
|
+
type PrimaryButtonsColorPalette = ValueOf<typeof PrimaryButtonsColorPalette>;
|
|
42
|
+
declare const ButtonsColorPalette: {
|
|
43
|
+
readonly white: "white";
|
|
44
|
+
readonly black: "black";
|
|
45
|
+
readonly info: "info";
|
|
46
|
+
readonly primary: string;
|
|
47
|
+
readonly secondary: string;
|
|
48
|
+
readonly error: string;
|
|
49
|
+
readonly success: string;
|
|
50
|
+
readonly warning: string;
|
|
51
|
+
readonly grey: string;
|
|
52
|
+
readonly radar: string;
|
|
53
|
+
};
|
|
54
|
+
type ButtonsColorPalette = ValueOf<typeof ButtonsColorPalette>;
|
|
55
|
+
declare const NotificationsColorPalette: {
|
|
56
|
+
readonly question: "question";
|
|
57
|
+
readonly 'no-data': "no-data";
|
|
58
|
+
readonly success: "success";
|
|
59
|
+
readonly warning: "warning";
|
|
60
|
+
readonly info: "info";
|
|
61
|
+
readonly primary: "primary";
|
|
62
|
+
readonly secondary: "secondary";
|
|
63
|
+
readonly error: "error";
|
|
64
|
+
};
|
|
65
|
+
type NotificationsColorPalette = ValueOf<typeof NotificationsColorPalette>;
|
|
66
|
+
declare const ProductColorPalette: {
|
|
67
|
+
readonly asm: "asm";
|
|
68
|
+
readonly 'brand-trust': "brand-trust";
|
|
69
|
+
readonly certificates: "certificates";
|
|
70
|
+
readonly ondmarc: "ondmarc";
|
|
71
|
+
readonly pulse: "pulse";
|
|
72
|
+
readonly radar: "radar";
|
|
73
|
+
readonly 'rojo-ds': "rojo-ds";
|
|
74
|
+
readonly 'vendor-secure': "vendor-secure";
|
|
75
|
+
readonly website: "website";
|
|
76
|
+
};
|
|
77
|
+
type ProductColorPalette = ValueOf<typeof ProductColorPalette>;
|
|
78
|
+
declare const PresentationColorPalette: {
|
|
79
|
+
readonly green: "green";
|
|
80
|
+
readonly pink: "pink";
|
|
81
|
+
readonly aqua: "aqua";
|
|
82
|
+
readonly brown: "brown";
|
|
83
|
+
readonly red: "red";
|
|
84
|
+
readonly yellow: "yellow";
|
|
85
|
+
readonly purple: "purple";
|
|
86
|
+
readonly orange: "orange";
|
|
87
|
+
readonly blue: "blue";
|
|
88
|
+
readonly grey: "grey";
|
|
89
|
+
};
|
|
90
|
+
type PresentationColorPalette = ValueOf<typeof PresentationColorPalette>;
|
|
91
|
+
declare const NeutralColorPalette: {
|
|
92
|
+
readonly black: "black";
|
|
93
|
+
readonly 'x-dark-grey': "x-dark-grey";
|
|
94
|
+
readonly 'dark-grey': "dark-grey";
|
|
95
|
+
readonly 'mid-grey': "mid-grey";
|
|
96
|
+
readonly 'light-grey': "light-grey";
|
|
97
|
+
readonly 'x-light-grey': "x-light-grey";
|
|
98
|
+
readonly white: "white";
|
|
99
|
+
};
|
|
100
|
+
type NeutralColorPalette = ValueOf<typeof NeutralColorPalette>;
|
|
101
|
+
|
|
102
|
+
export { ButtonsColorPalette, ColorPalette, NeutralColorPalette, NotificationsColorPalette, PresentationColorPalette, PrimaryButtonsColorPalette, PrimaryColorPalette, ProductColorPalette, SecondaryColorPalette, Theme };
|
package/types/colors.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { objectSpread2 as _objectSpread2 } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { Product } from './products.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Color palette.
|
|
6
|
+
*/
|
|
7
|
+
const Theme = {
|
|
8
|
+
light: 'light',
|
|
9
|
+
dark: 'dark'
|
|
10
|
+
};
|
|
11
|
+
const PrimaryColorPalette = {
|
|
12
|
+
primary: 'primary',
|
|
13
|
+
secondary: 'secondary',
|
|
14
|
+
error: 'error'
|
|
15
|
+
};
|
|
16
|
+
const SecondaryColorPalette = {
|
|
17
|
+
success: 'success',
|
|
18
|
+
warning: 'warning',
|
|
19
|
+
info: 'info'
|
|
20
|
+
};
|
|
21
|
+
const ColorPalette = _objectSpread2(_objectSpread2({}, PrimaryColorPalette), SecondaryColorPalette);
|
|
22
|
+
const PrimaryButtonsColorPalette = {
|
|
23
|
+
primary: 'primary',
|
|
24
|
+
secondary: 'secondary',
|
|
25
|
+
error: 'error',
|
|
26
|
+
success: 'success',
|
|
27
|
+
warning: 'warning',
|
|
28
|
+
grey: 'grey',
|
|
29
|
+
radar: 'radar'
|
|
30
|
+
};
|
|
31
|
+
const ButtonsColorPalette = _objectSpread2(_objectSpread2({}, PrimaryButtonsColorPalette), {}, {
|
|
32
|
+
white: 'white',
|
|
33
|
+
black: 'black',
|
|
34
|
+
info: 'info'
|
|
35
|
+
});
|
|
36
|
+
const NotificationsColorPalette = _objectSpread2(_objectSpread2({}, ColorPalette), {}, {
|
|
37
|
+
question: 'question',
|
|
38
|
+
'no-data': 'no-data'
|
|
39
|
+
});
|
|
40
|
+
const ProductColorPalette = Product;
|
|
41
|
+
const PresentationColorPalette = {
|
|
42
|
+
green: 'green',
|
|
43
|
+
pink: 'pink',
|
|
44
|
+
aqua: 'aqua',
|
|
45
|
+
brown: 'brown',
|
|
46
|
+
red: 'red',
|
|
47
|
+
yellow: 'yellow',
|
|
48
|
+
purple: 'purple',
|
|
49
|
+
orange: 'orange',
|
|
50
|
+
blue: 'blue',
|
|
51
|
+
grey: 'grey'
|
|
52
|
+
};
|
|
53
|
+
const NeutralColorPalette = {
|
|
54
|
+
black: 'black',
|
|
55
|
+
'x-dark-grey': 'x-dark-grey',
|
|
56
|
+
'dark-grey': 'dark-grey',
|
|
57
|
+
'mid-grey': 'mid-grey',
|
|
58
|
+
'light-grey': 'light-grey',
|
|
59
|
+
'x-light-grey': 'x-light-grey',
|
|
60
|
+
white: 'white'
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export { ButtonsColorPalette, ColorPalette, NeutralColorPalette, NotificationsColorPalette, PresentationColorPalette, PrimaryButtonsColorPalette, PrimaryColorPalette, ProductColorPalette, SecondaryColorPalette, Theme };
|
|
64
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.js","sources":["../../src/types/colors.ts"],"sourcesContent":["import { Product } from './products';\nimport { ValueOf } from './helpers';\n\n/**\n * Color palette.\n */\nexport const Theme = {\n light: 'light',\n dark: 'dark',\n} as const;\nexport type Theme = ValueOf<typeof Theme>;\n\nexport const PrimaryColorPalette = {\n primary: 'primary',\n secondary: 'secondary',\n error: 'error',\n} as const;\nexport type PrimaryColorPalette = ValueOf<typeof PrimaryColorPalette>;\n\nexport const SecondaryColorPalette = {\n success: 'success',\n warning: 'warning',\n info: 'info',\n} as const;\nexport type SecondaryColorPalette = ValueOf<typeof SecondaryColorPalette>;\n\nexport const ColorPalette = {\n ...PrimaryColorPalette,\n ...SecondaryColorPalette,\n} as const;\nexport type ColorPalette = PrimaryColorPalette & SecondaryColorPalette;\n\nexport const PrimaryButtonsColorPalette = {\n primary: 'primary',\n secondary: 'secondary',\n error: 'error',\n success: 'success',\n warning: 'warning',\n grey: 'grey',\n radar: 'radar',\n};\nexport const ButtonsColorPalette = {\n ...PrimaryButtonsColorPalette,\n white: 'white',\n black: 'black',\n info: 'info',\n} as const;\nexport type PrimaryButtonsColorPalette = ValueOf<typeof PrimaryButtonsColorPalette>;\nexport type ButtonsColorPalette = ValueOf<typeof ButtonsColorPalette>;\n\nexport const NotificationsColorPalette = {\n ...ColorPalette,\n question: 'question',\n 'no-data': 'no-data',\n} as const;\nexport type NotificationsColorPalette = ValueOf<typeof NotificationsColorPalette>;\n\nexport const ProductColorPalette = Product;\nexport type ProductColorPalette = ValueOf<typeof ProductColorPalette>;\n\nexport const PresentationColorPalette = {\n green: 'green',\n pink: 'pink',\n aqua: 'aqua',\n brown: 'brown',\n red: 'red',\n yellow: 'yellow',\n purple: 'purple',\n orange: 'orange',\n blue: 'blue',\n grey: 'grey',\n} as const;\nexport type PresentationColorPalette = ValueOf<typeof PresentationColorPalette>;\n\nexport const NeutralColorPalette = {\n black: 'black',\n 'x-dark-grey': 'x-dark-grey',\n 'dark-grey': 'dark-grey',\n 'mid-grey': 'mid-grey',\n 'light-grey': 'light-grey',\n 'x-light-grey': 'x-light-grey',\n white: 'white',\n} as const;\nexport type NeutralColorPalette = ValueOf<typeof NeutralColorPalette>;\n"],"names":["Theme","light","dark","PrimaryColorPalette","primary","secondary","error","SecondaryColorPalette","success","warning","info","ColorPalette","_objectSpread","PrimaryButtonsColorPalette","grey","radar","ButtonsColorPalette","white","black","NotificationsColorPalette","question","ProductColorPalette","Product","PresentationColorPalette","green","pink","aqua","brown","red","yellow","purple","orange","blue","NeutralColorPalette"],"mappings":";;;AAGA;AACA;AACA;AACO,MAAMA,KAAK,GAAG;AACnBC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,IAAI,EAAE,MAAA;AACR,EAAU;AAGH,MAAMC,mBAAmB,GAAG;AACjCC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,SAAS,EAAE,WAAW;AACtBC,EAAAA,KAAK,EAAE,OAAA;AACT,EAAU;AAGH,MAAMC,qBAAqB,GAAG;AACnCC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,IAAI,EAAE,MAAA;AACR,EAAU;AAGH,MAAMC,YAAY,GAAAC,cAAA,CAAAA,cAAA,CACpBT,EAAAA,EAAAA,mBAAmB,CACnBI,EAAAA,qBAAqB,EAChB;AAGH,MAAMM,0BAA0B,GAAG;AACxCT,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,SAAS,EAAE,WAAW;AACtBC,EAAAA,KAAK,EAAE,OAAO;AACdE,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,OAAO,EAAE,SAAS;AAClBK,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,KAAK,EAAE,OAAA;AACT,EAAC;MACYC,mBAAmB,GAAAJ,cAAA,CAAAA,cAAA,KAC3BC,0BAA0B,CAAA,EAAA,EAAA,EAAA;AAC7BI,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,KAAK,EAAE,OAAO;AACdR,EAAAA,IAAI,EAAE,MAAA;AAAM,CACJ,EAAA;MAIGS,yBAAyB,GAAAP,cAAA,CAAAA,cAAA,KACjCD,YAAY,CAAA,EAAA,EAAA,EAAA;AACfS,EAAAA,QAAQ,EAAE,UAAU;AACpB,EAAA,SAAS,EAAE,SAAA;AAAS,CACZ,EAAA;AAGH,MAAMC,mBAAmB,GAAGC,QAAO;AAGnC,MAAMC,wBAAwB,GAAG;AACtCC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,IAAI,EAAE,MAAM;AACZC,EAAAA,KAAK,EAAE,OAAO;AACdC,EAAAA,GAAG,EAAE,KAAK;AACVC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,MAAM,EAAE,QAAQ;AAChBC,EAAAA,IAAI,EAAE,MAAM;AACZlB,EAAAA,IAAI,EAAE,MAAA;AACR,EAAU;AAGH,MAAMmB,mBAAmB,GAAG;AACjCf,EAAAA,KAAK,EAAE,OAAO;AACd,EAAA,aAAa,EAAE,aAAa;AAC5B,EAAA,WAAW,EAAE,WAAW;AACxB,EAAA,UAAU,EAAE,UAAU;AACtB,EAAA,YAAY,EAAE,YAAY;AAC1B,EAAA,cAAc,EAAE,cAAc;AAC9BD,EAAAA,KAAK,EAAE,OAAA;AACT;;;;"}
|
package/types/fonts.d.ts
ADDED
package/types/fonts.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.js","sources":["../../src/types/fonts.ts"],"sourcesContent":["import { ValueOf } from './helpers';\n\n/**\n * Font.\n */\nexport const FontFamily = {\n poppins: 'poppins',\n 'source-code-pro': 'source-code-pro',\n} as const;\nexport type FontFamily = ValueOf<typeof FontFamily>;\n"],"names":["FontFamily","poppins"],"mappings":"AAEA;AACA;AACA;AACO,MAAMA,UAAU,GAAG;AACxBC,EAAAA,OAAO,EAAE,SAAS;AAClB,EAAA,iBAAiB,EAAE,iBAAA;AACrB;;;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Ref, ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
/** Component Type. */
|
|
4
|
+
type Comp<P, T = HTMLElement> = {
|
|
5
|
+
(props: P & {
|
|
6
|
+
ref?: Ref<T>;
|
|
7
|
+
}): ReactElement | null;
|
|
8
|
+
/** React component type. */
|
|
9
|
+
readonly $$typeof?: symbol;
|
|
10
|
+
/** Component name. */
|
|
11
|
+
displayName?: string;
|
|
12
|
+
/** Component base class name. */
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* JS falsy values.
|
|
17
|
+
* (excluding `NaN` as it can't be distinguished from `number`)
|
|
18
|
+
*/
|
|
19
|
+
type Falsy = false | undefined | null | 0 | '';
|
|
20
|
+
/** Get types of the values of a record. */
|
|
21
|
+
type ValueOf<T extends Record<any, any>> = T[keyof T];
|
|
22
|
+
|
|
23
|
+
export { Comp, Falsy, ValueOf };
|