@telus-uds/components-base 1.96.0 → 1.97.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -2
- package/babel.config.cjs +35 -0
- package/{jest.config-android.js → jest.config-android.cjs} +1 -1
- package/{jest.config-ios.js → jest.config-ios.cjs} +1 -1
- package/{jest.config-web.js → jest.config-web.cjs} +1 -1
- package/jest.config.cjs +40 -0
- package/lib/A11yInfoProvider/index.js +29 -35
- package/lib/A11yText/index.js +16 -24
- package/lib/ActionCard/ActionCard.js +47 -55
- package/lib/ActionCard/index.js +2 -10
- package/lib/ActivityIndicator/Spinner.js +20 -28
- package/lib/ActivityIndicator/Spinner.native.js +32 -40
- package/lib/ActivityIndicator/index.js +18 -22
- package/lib/ActivityIndicator/shared.js +12 -23
- package/lib/Autocomplete/Autocomplete.js +90 -99
- package/lib/Autocomplete/Loading.js +14 -22
- package/lib/Autocomplete/Suggestions.js +23 -31
- package/lib/Autocomplete/constants.js +4 -14
- package/lib/Autocomplete/dictionary.js +2 -9
- package/lib/Autocomplete/index.js +2 -10
- package/lib/Badge/Badge.js +18 -26
- package/lib/Badge/index.js +2 -10
- package/lib/BaseProvider/HydrationContext.js +13 -23
- package/lib/BaseProvider/index.js +24 -29
- package/lib/Box/Box.js +60 -68
- package/lib/Box/backgroundImageStylesMap.js +2 -9
- package/lib/Box/index.js +2 -10
- package/lib/Button/Button.js +15 -25
- package/lib/Button/ButtonBase.js +37 -46
- package/lib/Button/ButtonDropdown.js +37 -47
- package/lib/Button/ButtonGroup.js +53 -61
- package/lib/Button/ButtonLink.js +21 -29
- package/lib/Button/index.js +5 -34
- package/lib/Button/propTypes.js +16 -25
- package/lib/Card/Card.js +47 -55
- package/lib/Card/CardBase.js +27 -35
- package/lib/Card/PressableCardBase.js +26 -35
- package/lib/Card/index.js +4 -33
- package/lib/CardGroup/CardGroup.js +45 -55
- package/lib/CardGroup/dictionary.js +2 -9
- package/lib/CardGroup/index.js +2 -10
- package/lib/Carousel/Carousel.js +138 -146
- package/lib/Carousel/CarouselContext.js +19 -27
- package/lib/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +15 -22
- package/lib/Carousel/CarouselItem/CarouselItem.js +44 -56
- package/lib/Carousel/CarouselItem/index.js +2 -10
- package/lib/Carousel/CarouselStepTracker/CarouselStepTracker.js +12 -20
- package/lib/Carousel/CarouselStepTracker/index.js +2 -10
- package/lib/Carousel/CarouselTabs/CarouselTabs.js +16 -23
- package/lib/Carousel/CarouselTabs/CarouselTabsPanel.js +20 -28
- package/lib/Carousel/CarouselTabs/CarouselTabsPanelItem.js +23 -31
- package/lib/Carousel/CarouselTabs/index.js +2 -10
- package/lib/Carousel/CarouselThumbnail.js +19 -27
- package/lib/Carousel/CarouselThumbnailNavigation.js +22 -30
- package/lib/Carousel/dictionary.js +2 -9
- package/lib/Carousel/index.js +3 -36
- package/lib/Checkbox/Checkbox.js +52 -60
- package/lib/Checkbox/CheckboxButton.js +32 -41
- package/lib/Checkbox/CheckboxGroup.js +41 -49
- package/lib/Checkbox/CheckboxInput.js +15 -21
- package/lib/Checkbox/CheckboxInput.native.js +1 -8
- package/lib/Checkbox/index.js +3 -17
- package/lib/CheckboxCard/CheckboxCard.js +45 -55
- package/lib/CheckboxCard/index.js +2 -10
- package/lib/CheckboxCardGroup/CheckboxCardGroup.js +42 -52
- package/lib/CheckboxCardGroup/index.js +2 -10
- package/lib/ColourToggle/ColourBubble.js +23 -31
- package/lib/ColourToggle/ColourToggle.js +27 -35
- package/lib/ColourToggle/index.js +2 -10
- package/lib/Divider/Divider.js +23 -31
- package/lib/Divider/index.js +2 -10
- package/lib/DownloadApp/DownloadApp.js +32 -40
- package/lib/DownloadApp/dictionary.js +2 -9
- package/lib/DownloadApp/index.js +2 -10
- package/lib/ExpandCollapse/Accordion.js +7 -13
- package/lib/ExpandCollapse/Control.js +26 -34
- package/lib/ExpandCollapse/ExpandCollapse.js +22 -30
- package/lib/ExpandCollapse/Panel.js +43 -51
- package/lib/ExpandCollapse/dictionary.js +2 -9
- package/lib/ExpandCollapse/index.js +7 -20
- package/lib/Feedback/Feedback.js +33 -41
- package/lib/Feedback/index.js +2 -10
- package/lib/Fieldset/Fieldset.js +37 -43
- package/lib/Fieldset/FieldsetContainer.js +17 -25
- package/lib/Fieldset/FieldsetContainer.native.js +12 -20
- package/lib/Fieldset/Legend.js +10 -16
- package/lib/Fieldset/Legend.native.js +11 -17
- package/lib/Fieldset/cssReset.js +2 -9
- package/lib/Fieldset/index.js +2 -10
- package/lib/FileUpload/FileUpload.js +50 -58
- package/lib/FileUpload/NotificationContent.js +12 -18
- package/lib/FileUpload/dictionary.js +2 -9
- package/lib/FileUpload/index.js +2 -10
- package/lib/FlexGrid/Col/Col.js +35 -43
- package/lib/FlexGrid/Col/index.js +2 -10
- package/lib/FlexGrid/FlexGrid.js +38 -46
- package/lib/FlexGrid/Row/Row.js +24 -32
- package/lib/FlexGrid/Row/index.js +2 -10
- package/lib/FlexGrid/helpers/index.js +1 -8
- package/lib/FlexGrid/index.js +2 -10
- package/lib/FlexGrid/providers/GutterContext.js +3 -11
- package/lib/Footnote/Footnote.js +63 -71
- package/lib/Footnote/FootnoteLink.js +30 -38
- package/lib/Footnote/dictionary.js +2 -9
- package/lib/Footnote/index.js +4 -12
- package/lib/HorizontalScroll/HorizontalScroll.js +32 -41
- package/lib/HorizontalScroll/HorizontalScrollButton.js +25 -33
- package/lib/HorizontalScroll/ScrollViewEnd.js +12 -20
- package/lib/HorizontalScroll/ScrollViewEnd.native.js +9 -16
- package/lib/HorizontalScroll/dictionary.js +2 -9
- package/lib/HorizontalScroll/index.js +11 -28
- package/lib/HorizontalScroll/itemPositions.js +17 -27
- package/lib/Icon/Icon.js +21 -30
- package/lib/Icon/IconText.js +29 -39
- package/lib/Icon/index.js +4 -25
- package/lib/IconButton/IconButton.js +35 -42
- package/lib/IconButton/index.js +2 -10
- package/lib/InputLabel/InputLabel.js +38 -47
- package/lib/InputLabel/LabelContent.js +8 -16
- package/lib/InputLabel/LabelContent.native.js +8 -17
- package/lib/InputLabel/index.js +2 -10
- package/lib/InputSupports/InputSupports.js +27 -35
- package/lib/InputSupports/index.js +2 -10
- package/lib/InputSupports/useInputSupports.js +5 -13
- package/lib/Link/ChevronLink.js +22 -28
- package/lib/Link/InlinePressable.js +13 -19
- package/lib/Link/InlinePressable.native.js +14 -23
- package/lib/Link/Link.js +9 -17
- package/lib/Link/LinkBase.js +40 -48
- package/lib/Link/TextButton.js +16 -22
- package/lib/Link/index.js +5 -34
- package/lib/List/List.js +22 -30
- package/lib/List/ListItem.js +12 -18
- package/lib/List/ListItemBase.js +33 -40
- package/lib/List/ListItemContent.js +22 -31
- package/lib/List/ListItemMark.js +24 -33
- package/lib/List/PressableListItemBase.js +32 -40
- package/lib/List/index.js +5 -24
- package/lib/Listbox/GroupControl.js +29 -33
- package/lib/Listbox/Listbox.js +40 -50
- package/lib/Listbox/ListboxContext.js +4 -12
- package/lib/Listbox/ListboxGroup.js +31 -40
- package/lib/Listbox/ListboxItem.js +23 -31
- package/lib/Listbox/ListboxOverlay.js +26 -35
- package/lib/Listbox/PressableItem.js +22 -30
- package/lib/Listbox/index.js +2 -10
- package/lib/Modal/Modal.js +75 -85
- package/lib/Modal/ModalContent.js +51 -58
- package/lib/Modal/WebModal.js +15 -23
- package/lib/Modal/dictionary.js +2 -9
- package/lib/Modal/index.js +2 -10
- package/lib/MultiSelectFilter/ModalOverlay.js +45 -53
- package/lib/MultiSelectFilter/MultiSelectFilter.js +110 -118
- package/lib/MultiSelectFilter/dictionary.js +2 -9
- package/lib/MultiSelectFilter/index.js +2 -10
- package/lib/Notification/Notification.js +59 -67
- package/lib/Notification/dictionary.js +2 -9
- package/lib/Notification/index.js +2 -10
- package/lib/OrderedList/Item.js +31 -39
- package/lib/OrderedList/ItemBase.js +13 -22
- package/lib/OrderedList/OrderedList.js +17 -25
- package/lib/OrderedList/OrderedListBase.js +12 -21
- package/lib/OrderedList/index.js +2 -10
- package/lib/Pagination/PageButton.js +22 -32
- package/lib/Pagination/Pagination.js +48 -51
- package/lib/Pagination/SideButton.js +25 -32
- package/lib/Pagination/constants.js +3 -0
- package/lib/Pagination/dictionary.js +2 -9
- package/lib/Pagination/index.js +2 -10
- package/lib/Pagination/usePagination.js +14 -12
- package/lib/Portal/Portal.js +8 -15
- package/lib/Portal/Portal.native.js +2 -9
- package/lib/Portal/index.js +2 -10
- package/lib/PriceLockup/PriceLockup.js +37 -45
- package/lib/PriceLockup/index.js +2 -10
- package/lib/PriceLockup/utils/renderFootnoteContent.js +20 -28
- package/lib/PriceLockup/utils/renderFootnoteLinks.js +5 -13
- package/lib/PriceLockup/utils/renderPrice.js +30 -38
- package/lib/PriceLockup/utils/renderTypography.js +5 -13
- package/lib/ProductCard/ProductCard.js +62 -70
- package/lib/ProductCard/dictionary.js +2 -9
- package/lib/ProductCard/index.js +2 -10
- package/lib/ProductCardGroup/ProductCardGroup.js +20 -28
- package/lib/ProductCardGroup/index.js +2 -10
- package/lib/Progress/Progress.js +15 -23
- package/lib/Progress/ProgressBar.js +23 -31
- package/lib/Progress/ProgressBarBackground.js +10 -18
- package/lib/Progress/index.js +4 -12
- package/lib/QuickLinks/QuickLinks.js +23 -29
- package/lib/QuickLinks/QuickLinksCard.js +14 -20
- package/lib/QuickLinks/QuickLinksItem.js +22 -28
- package/lib/QuickLinks/index.js +4 -12
- package/lib/QuickLinksFeature/QuickLinksFeature.js +20 -27
- package/lib/QuickLinksFeature/QuickLinksFeatureItem.js +31 -38
- package/lib/QuickLinksFeature/index.js +4 -12
- package/lib/Radio/Radio.js +43 -53
- package/lib/Radio/RadioButton.js +34 -43
- package/lib/Radio/RadioGroup.js +43 -51
- package/lib/Radio/RadioInput.js +15 -21
- package/lib/Radio/RadioInput.native.js +1 -8
- package/lib/Radio/index.js +3 -17
- package/lib/RadioCard/RadioCard.js +43 -53
- package/lib/RadioCard/RadioCardGroup.js +42 -52
- package/lib/RadioCard/index.js +3 -17
- package/lib/Responsive/Responsive.js +16 -22
- package/lib/Responsive/ResponsiveProp.js +13 -21
- package/lib/Responsive/ResponsiveWithMediaQueryStyleSheet.js +15 -23
- package/lib/Responsive/index.js +2 -10
- package/lib/Search/Search.js +47 -55
- package/lib/Search/dictionary.js +2 -9
- package/lib/Search/index.js +2 -10
- package/lib/Select/Group.js +9 -17
- package/lib/Select/Group.native.js +5 -13
- package/lib/Select/Item.js +8 -16
- package/lib/Select/Item.native.js +1 -8
- package/lib/Select/Picker.js +27 -35
- package/lib/Select/Picker.native.js +34 -41
- package/lib/Select/Select.js +45 -54
- package/lib/Select/constants.js +4 -14
- package/lib/Select/index.js +6 -14
- package/lib/SideNav/Item.js +29 -37
- package/lib/SideNav/ItemContent.js +17 -26
- package/lib/SideNav/ItemsGroup.js +25 -32
- package/lib/SideNav/SideNav.js +28 -38
- package/lib/SideNav/index.js +1 -13
- package/lib/Skeleton/Skeleton.js +32 -40
- package/lib/Skeleton/index.js +2 -10
- package/lib/Skeleton/skeleton.constant.js +2 -10
- package/lib/Skeleton/skeletonWebAnimation.js +1 -8
- package/lib/Skeleton/useSkeletonNativeAnimation.js +14 -22
- package/lib/SkipLink/SkipLink.js +24 -33
- package/lib/SkipLink/index.js +2 -10
- package/lib/Spacer/Spacer.js +15 -21
- package/lib/Spacer/index.js +2 -10
- package/lib/StackView/StackView.js +28 -36
- package/lib/StackView/StackWrap.js +14 -21
- package/lib/StackView/StackWrap.native.js +2 -9
- package/lib/StackView/StackWrapBox.js +27 -35
- package/lib/StackView/StackWrapGap.js +22 -30
- package/lib/StackView/common.js +4 -13
- package/lib/StackView/getStackedContent.js +14 -22
- package/lib/StackView/index.js +5 -24
- package/lib/Status/Status.js +27 -35
- package/lib/Status/index.js +2 -10
- package/lib/StepTracker/Step.js +35 -43
- package/lib/StepTracker/StepTracker.js +38 -46
- package/lib/StepTracker/dictionary.js +2 -9
- package/lib/StepTracker/index.js +2 -10
- package/lib/TabBar/TabBar.js +28 -36
- package/lib/TabBar/TabBarItem.js +33 -42
- package/lib/TabBar/index.js +2 -10
- package/lib/Tabs/Tabs.js +38 -48
- package/lib/Tabs/TabsItem.js +45 -53
- package/lib/Tabs/index.js +2 -10
- package/lib/Tags/Tags.js +47 -55
- package/lib/Tags/index.js +2 -10
- package/lib/TextInput/TextArea.js +19 -27
- package/lib/TextInput/TextInput.js +18 -26
- package/lib/TextInput/TextInputBase.js +64 -73
- package/lib/TextInput/dictionary.js +2 -9
- package/lib/TextInput/index.js +3 -20
- package/lib/TextInput/propTypes.js +8 -15
- package/lib/ThemeProvider/ThemeProvider.js +25 -36
- package/lib/ThemeProvider/index.js +7 -60
- package/lib/ThemeProvider/useResponsiveThemeTokens.js +10 -18
- package/lib/ThemeProvider/useSetTheme.js +5 -12
- package/lib/ThemeProvider/useTheme.js +4 -11
- package/lib/ThemeProvider/useThemeTokens.js +15 -24
- package/lib/ThemeProvider/utils/index.js +2 -27
- package/lib/ThemeProvider/utils/styles.js +12 -24
- package/lib/ThemeProvider/utils/theme-tokens.js +19 -34
- package/lib/Timeline/Timeline.js +28 -34
- package/lib/Timeline/index.js +2 -10
- package/lib/ToggleSwitch/ToggleSwitch.js +40 -48
- package/lib/ToggleSwitch/ToggleSwitchGroup.js +43 -51
- package/lib/ToggleSwitch/index.js +3 -20
- package/lib/Tooltip/Backdrop.js +8 -16
- package/lib/Tooltip/Backdrop.native.js +16 -22
- package/lib/Tooltip/Tooltip.js +42 -50
- package/lib/Tooltip/Tooltip.native.js +80 -61
- package/lib/Tooltip/dictionary.js +2 -9
- package/lib/Tooltip/getTooltipPosition.js +1 -9
- package/lib/Tooltip/index.js +5 -13
- package/lib/Tooltip/shared.js +17 -20
- package/lib/TooltipButton/TooltipButton.js +25 -33
- package/lib/TooltipButton/index.js +2 -10
- package/lib/Typography/Typography.js +39 -46
- package/lib/Typography/index.js +2 -10
- package/lib/Validator/Validator.js +42 -50
- package/lib/Validator/index.js +2 -10
- package/lib/ViewportProvider/ViewportProvider.js +13 -19
- package/lib/ViewportProvider/index.js +3 -23
- package/lib/ViewportProvider/useViewport.js +3 -11
- package/lib/ViewportProvider/useViewportListener.js +10 -17
- package/lib/index.js +71 -772
- package/lib/server.js +4 -40
- package/lib/utils/BaseView/BaseView.js +14 -20
- package/lib/utils/BaseView/BaseView.native.js +2 -10
- package/lib/utils/BaseView/index.js +2 -10
- package/lib/utils/a11y/index.js +2 -27
- package/lib/utils/a11y/semantics.js +11 -35
- package/lib/utils/a11y/textSize.js +7 -16
- package/lib/utils/animation/index.js +2 -13
- package/lib/utils/animation/useVerticalExpandAnimation.js +19 -26
- package/lib/utils/children.js +12 -20
- package/lib/utils/containUniqueFields.js +1 -8
- package/lib/utils/convertFromMegaByteToByte.js +1 -7
- package/lib/utils/floating-ui/index.js +1 -42
- package/lib/utils/floating-ui/index.native.js +1 -42
- package/lib/utils/formatImageSource.js +1 -8
- package/lib/utils/hasOwnProperty.js +1 -7
- package/lib/utils/htmlAttrs.js +11 -19
- package/lib/utils/index.js +25 -245
- package/lib/utils/info/index.js +6 -13
- package/lib/utils/info/platform/index.js +8 -13
- package/lib/utils/info/platform/platform.android.js +1 -8
- package/lib/utils/info/platform/platform.ios.js +1 -8
- package/lib/utils/info/platform/platform.js +1 -8
- package/lib/utils/info/platform/platform.native.js +1 -8
- package/lib/utils/info/versions.js +4 -11
- package/lib/utils/input.js +13 -21
- package/lib/utils/pressability.js +14 -22
- package/lib/utils/props/a11yProps.js +90 -98
- package/lib/utils/props/clickProps.js +4 -12
- package/lib/utils/props/componentPropType.js +1 -7
- package/lib/utils/props/copyPropTypes.js +2 -10
- package/lib/utils/props/getPropSelector.js +6 -11
- package/lib/utils/props/handlerProps.js +23 -31
- package/lib/utils/props/hrefAttrsProp.js +6 -13
- package/lib/utils/props/index.js +19 -168
- package/lib/utils/props/inputSupportsProps.js +12 -20
- package/lib/utils/props/linkProps.js +16 -24
- package/lib/utils/props/paddingProp.js +8 -16
- package/lib/utils/props/pressProps.js +22 -31
- package/lib/utils/props/rectProp.js +8 -16
- package/lib/utils/props/responsiveProps.js +5 -13
- package/lib/utils/props/selectSystemProps.js +1 -7
- package/lib/utils/props/spacingProps.js +12 -19
- package/lib/utils/props/textInputProps.js +56 -62
- package/lib/utils/props/textProps.js +18 -24
- package/lib/utils/props/tokens.js +16 -26
- package/lib/utils/props/variantProp.js +4 -11
- package/lib/utils/props/viewProps.js +10 -18
- package/lib/utils/ssr-media-query/create-stylesheet/create-stylesheet-mobile.js +8 -16
- package/lib/utils/ssr-media-query/create-stylesheet/index.android.js +2 -10
- package/lib/utils/ssr-media-query/create-stylesheet/index.ios.js +2 -10
- package/lib/utils/ssr-media-query/create-stylesheet/index.js +12 -20
- package/lib/utils/ssr-media-query/hash.js +1 -7
- package/lib/utils/ssr-media-query/index.js +4 -17
- package/lib/utils/ssr-media-query/utils/common.js +1 -12
- package/lib/utils/ssr-media-query/utils/create-declaration-block.js +6 -14
- package/lib/utils/ssr-media-query/utils/create-media-query-styles.js +5 -12
- package/lib/utils/ssr-media-query/utils/hyphenate-style-name.js +1 -8
- package/lib/utils/ssr-media-query/utils/inject.js +8 -18
- package/lib/utils/ssr.js +19 -28
- package/lib/utils/transformGradient.js +3 -11
- package/lib/utils/useCopy.js +2 -10
- package/lib/utils/useHash.js +7 -14
- package/lib/utils/useHash.native.js +1 -8
- package/lib/utils/useOverlaidPosition.js +17 -25
- package/lib/utils/useResponsiveProp.js +10 -19
- package/lib/utils/useSafeLayoutEffect.js +6 -13
- package/lib/utils/useScrollBlocking.js +10 -17
- package/lib/utils/useScrollBlocking.native.js +1 -8
- package/lib/utils/useSpacingScale.js +7 -14
- package/lib/utils/useUniqueId.js +3 -10
- package/lib/utils/withLinkRouter.js +13 -19
- package/package.json +20 -25
- package/src/A11yInfoProvider/index.jsx +5 -2
- package/src/ActivityIndicator/index.jsx +12 -3
- package/src/BaseProvider/index.jsx +5 -2
- package/src/Carousel/Carousel.jsx +1 -1
- package/src/Carousel/CarouselItem/CarouselItem.jsx +16 -22
- package/src/Icon/IconText.jsx +0 -1
- package/src/InputLabel/InputLabel.jsx +2 -3
- package/src/List/ListItemBase.jsx +6 -1
- package/src/Listbox/GroupControl.jsx +6 -1
- package/src/Modal/ModalContent.jsx +3 -2
- package/src/Pagination/Pagination.jsx +9 -2
- package/src/Pagination/constants.js +3 -0
- package/src/Pagination/usePagination.js +14 -3
- package/src/TextInput/TextInputBase.jsx +1 -1
- package/src/Timeline/Timeline.jsx +6 -2
- package/src/Tooltip/Tooltip.native.jsx +31 -3
- package/src/Tooltip/shared.js +5 -0
- package/src/index.js +9 -10
- package/src/utils/a11y/semantics.js +0 -7
- package/types/FileUpload.d.ts +40 -0
- package/types/index.d.ts +3 -0
- package/lib-module/A11yInfoProvider/index.js +0 -62
- package/lib-module/A11yText/index.js +0 -68
- package/lib-module/ActionCard/ActionCard.js +0 -343
- package/lib-module/ActionCard/index.js +0 -2
- package/lib-module/ActivityIndicator/Spinner.js +0 -80
- package/lib-module/ActivityIndicator/Spinner.native.js +0 -144
- package/lib-module/ActivityIndicator/index.js +0 -44
- package/lib-module/ActivityIndicator/shared.js +0 -14
- package/lib-module/Autocomplete/Autocomplete.js +0 -481
- package/lib-module/Autocomplete/Loading.js +0 -36
- package/lib-module/Autocomplete/Suggestions.js +0 -66
- package/lib-module/Autocomplete/constants.js +0 -4
- package/lib-module/Autocomplete/dictionary.js +0 -12
- package/lib-module/Autocomplete/index.js +0 -2
- package/lib-module/Badge/Badge.js +0 -102
- package/lib-module/Badge/index.js +0 -2
- package/lib-module/BaseProvider/HydrationContext.js +0 -48
- package/lib-module/BaseProvider/index.js +0 -38
- package/lib-module/Box/Box.js +0 -379
- package/lib-module/Box/backgroundImageStylesMap.js +0 -94
- package/lib-module/Box/index.js +0 -2
- package/lib-module/Button/Button.js +0 -34
- package/lib-module/Button/ButtonBase.js +0 -347
- package/lib-module/Button/ButtonDropdown.js +0 -173
- package/lib-module/Button/ButtonGroup.js +0 -272
- package/lib-module/Button/ButtonLink.js +0 -50
- package/lib-module/Button/index.js +0 -5
- package/lib-module/Button/propTypes.js +0 -46
- package/lib-module/Card/Card.js +0 -330
- package/lib-module/Card/CardBase.js +0 -114
- package/lib-module/Card/PressableCardBase.js +0 -112
- package/lib-module/Card/index.js +0 -4
- package/lib-module/CardGroup/CardGroup.js +0 -210
- package/lib-module/CardGroup/dictionary.js +0 -8
- package/lib-module/CardGroup/index.js +0 -2
- package/lib-module/Carousel/Carousel.js +0 -894
- package/lib-module/Carousel/CarouselContext.js +0 -51
- package/lib-module/Carousel/CarouselFirstFocus/CarouselFirstFocus.js +0 -53
- package/lib-module/Carousel/CarouselItem/CarouselItem.js +0 -150
- package/lib-module/Carousel/CarouselItem/index.js +0 -2
- package/lib-module/Carousel/CarouselStepTracker/CarouselStepTracker.js +0 -54
- package/lib-module/Carousel/CarouselStepTracker/index.js +0 -2
- package/lib-module/Carousel/CarouselTabs/CarouselTabs.js +0 -50
- package/lib-module/Carousel/CarouselTabs/CarouselTabsPanel.js +0 -89
- package/lib-module/Carousel/CarouselTabs/CarouselTabsPanelItem.js +0 -118
- package/lib-module/Carousel/CarouselTabs/index.js +0 -2
- package/lib-module/Carousel/CarouselThumbnail.js +0 -113
- package/lib-module/Carousel/CarouselThumbnailNavigation.js +0 -71
- package/lib-module/Carousel/dictionary.js +0 -22
- package/lib-module/Carousel/index.js +0 -3
- package/lib-module/Checkbox/Checkbox.js +0 -343
- package/lib-module/Checkbox/CheckboxButton.js +0 -164
- package/lib-module/Checkbox/CheckboxGroup.js +0 -240
- package/lib-module/Checkbox/CheckboxInput.js +0 -50
- package/lib-module/Checkbox/CheckboxInput.native.js +0 -5
- package/lib-module/Checkbox/index.js +0 -3
- package/lib-module/CheckboxCard/CheckboxCard.js +0 -183
- package/lib-module/CheckboxCard/index.js +0 -2
- package/lib-module/CheckboxCardGroup/CheckboxCardGroup.js +0 -206
- package/lib-module/CheckboxCardGroup/index.js +0 -2
- package/lib-module/ColourToggle/ColourBubble.js +0 -126
- package/lib-module/ColourToggle/ColourToggle.js +0 -92
- package/lib-module/ColourToggle/index.js +0 -2
- package/lib-module/Divider/Divider.js +0 -133
- package/lib-module/Divider/index.js +0 -2
- package/lib-module/DownloadApp/DownloadApp.js +0 -160
- package/lib-module/DownloadApp/dictionary.js +0 -10
- package/lib-module/DownloadApp/index.js +0 -2
- package/lib-module/ExpandCollapse/Accordion.js +0 -15
- package/lib-module/ExpandCollapse/Control.js +0 -165
- package/lib-module/ExpandCollapse/ExpandCollapse.js +0 -98
- package/lib-module/ExpandCollapse/Panel.js +0 -242
- package/lib-module/ExpandCollapse/dictionary.js +0 -10
- package/lib-module/ExpandCollapse/index.js +0 -7
- package/lib-module/Feedback/Feedback.js +0 -161
- package/lib-module/Feedback/index.js +0 -2
- package/lib-module/Fieldset/Fieldset.js +0 -194
- package/lib-module/Fieldset/FieldsetContainer.js +0 -48
- package/lib-module/Fieldset/FieldsetContainer.native.js +0 -32
- package/lib-module/Fieldset/Legend.js +0 -24
- package/lib-module/Fieldset/Legend.native.js +0 -31
- package/lib-module/Fieldset/cssReset.js +0 -14
- package/lib-module/Fieldset/index.js +0 -2
- package/lib-module/FileUpload/FileUpload.js +0 -329
- package/lib-module/FileUpload/NotificationContent.js +0 -55
- package/lib-module/FileUpload/dictionary.js +0 -40
- package/lib-module/FileUpload/index.js +0 -2
- package/lib-module/FlexGrid/Col/Col.js +0 -257
- package/lib-module/FlexGrid/Col/index.js +0 -2
- package/lib-module/FlexGrid/FlexGrid.js +0 -158
- package/lib-module/FlexGrid/Row/Row.js +0 -181
- package/lib-module/FlexGrid/Row/index.js +0 -2
- package/lib-module/FlexGrid/helpers/index.js +0 -15
- package/lib-module/FlexGrid/index.js +0 -2
- package/lib-module/FlexGrid/providers/GutterContext.js +0 -3
- package/lib-module/Footnote/Footnote.js +0 -317
- package/lib-module/Footnote/FootnoteLink.js +0 -107
- package/lib-module/Footnote/dictionary.js +0 -12
- package/lib-module/Footnote/index.js +0 -4
- package/lib-module/HorizontalScroll/HorizontalScroll.js +0 -165
- package/lib-module/HorizontalScroll/HorizontalScrollButton.js +0 -79
- package/lib-module/HorizontalScroll/ScrollViewEnd.js +0 -46
- package/lib-module/HorizontalScroll/ScrollViewEnd.native.js +0 -26
- package/lib-module/HorizontalScroll/dictionary.js +0 -11
- package/lib-module/HorizontalScroll/index.js +0 -11
- package/lib-module/HorizontalScroll/itemPositions.js +0 -113
- package/lib-module/Icon/Icon.js +0 -93
- package/lib-module/Icon/IconText.js +0 -114
- package/lib-module/Icon/index.js +0 -4
- package/lib-module/IconButton/IconButton.js +0 -203
- package/lib-module/IconButton/index.js +0 -2
- package/lib-module/InputLabel/InputLabel.js +0 -146
- package/lib-module/InputLabel/LabelContent.js +0 -28
- package/lib-module/InputLabel/LabelContent.native.js +0 -18
- package/lib-module/InputLabel/index.js +0 -2
- package/lib-module/InputSupports/InputSupports.js +0 -108
- package/lib-module/InputSupports/index.js +0 -2
- package/lib-module/InputSupports/useInputSupports.js +0 -31
- package/lib-module/Link/ChevronLink.js +0 -68
- package/lib-module/Link/InlinePressable.js +0 -48
- package/lib-module/Link/InlinePressable.native.js +0 -87
- package/lib-module/Link/Link.js +0 -28
- package/lib-module/Link/LinkBase.js +0 -269
- package/lib-module/Link/TextButton.js +0 -43
- package/lib-module/Link/index.js +0 -5
- package/lib-module/List/List.js +0 -77
- package/lib-module/List/ListItem.js +0 -32
- package/lib-module/List/ListItemBase.js +0 -164
- package/lib-module/List/ListItemContent.js +0 -73
- package/lib-module/List/ListItemMark.js +0 -126
- package/lib-module/List/PressableListItemBase.js +0 -112
- package/lib-module/List/index.js +0 -5
- package/lib-module/Listbox/GroupControl.js +0 -102
- package/lib-module/Listbox/Listbox.js +0 -172
- package/lib-module/Listbox/ListboxContext.js +0 -4
- package/lib-module/Listbox/ListboxGroup.js +0 -125
- package/lib-module/Listbox/ListboxItem.js +0 -76
- package/lib-module/Listbox/ListboxOverlay.js +0 -78
- package/lib-module/Listbox/PressableItem.js +0 -140
- package/lib-module/Listbox/index.js +0 -2
- package/lib-module/Modal/Modal.js +0 -373
- package/lib-module/Modal/ModalContent.js +0 -179
- package/lib-module/Modal/WebModal.js +0 -76
- package/lib-module/Modal/dictionary.js +0 -9
- package/lib-module/Modal/index.js +0 -2
- package/lib-module/MultiSelectFilter/ModalOverlay.js +0 -156
- package/lib-module/MultiSelectFilter/MultiSelectFilter.js +0 -526
- package/lib-module/MultiSelectFilter/dictionary.js +0 -12
- package/lib-module/MultiSelectFilter/index.js +0 -2
- package/lib-module/Notification/Notification.js +0 -429
- package/lib-module/Notification/dictionary.js +0 -8
- package/lib-module/Notification/index.js +0 -2
- package/lib-module/OrderedList/Item.js +0 -160
- package/lib-module/OrderedList/ItemBase.js +0 -43
- package/lib-module/OrderedList/OrderedList.js +0 -64
- package/lib-module/OrderedList/OrderedListBase.js +0 -36
- package/lib-module/OrderedList/index.js +0 -2
- package/lib-module/Pagination/PageButton.js +0 -74
- package/lib-module/Pagination/Pagination.js +0 -211
- package/lib-module/Pagination/SideButton.js +0 -113
- package/lib-module/Pagination/dictionary.js +0 -18
- package/lib-module/Pagination/index.js +0 -2
- package/lib-module/Pagination/usePagination.js +0 -69
- package/lib-module/Portal/Portal.js +0 -50
- package/lib-module/Portal/Portal.native.js +0 -2
- package/lib-module/Portal/index.js +0 -2
- package/lib-module/PriceLockup/PriceLockup.js +0 -225
- package/lib-module/PriceLockup/index.js +0 -2
- package/lib-module/PriceLockup/utils/renderFootnoteContent.js +0 -87
- package/lib-module/PriceLockup/utils/renderFootnoteLinks.js +0 -28
- package/lib-module/PriceLockup/utils/renderPrice.js +0 -141
- package/lib-module/PriceLockup/utils/renderTypography.js +0 -23
- package/lib-module/ProductCard/ProductCard.js +0 -232
- package/lib-module/ProductCard/dictionary.js +0 -38
- package/lib-module/ProductCard/index.js +0 -2
- package/lib-module/ProductCardGroup/ProductCardGroup.js +0 -70
- package/lib-module/ProductCardGroup/index.js +0 -2
- package/lib-module/Progress/Progress.js +0 -88
- package/lib-module/Progress/ProgressBar.js +0 -133
- package/lib-module/Progress/ProgressBarBackground.js +0 -40
- package/lib-module/Progress/index.js +0 -4
- package/lib-module/QuickLinks/QuickLinks.js +0 -78
- package/lib-module/QuickLinks/QuickLinksCard.js +0 -33
- package/lib-module/QuickLinks/QuickLinksItem.js +0 -51
- package/lib-module/QuickLinks/index.js +0 -4
- package/lib-module/QuickLinksFeature/QuickLinksFeature.js +0 -69
- package/lib-module/QuickLinksFeature/QuickLinksFeatureItem.js +0 -147
- package/lib-module/QuickLinksFeature/index.js +0 -4
- package/lib-module/Radio/Radio.js +0 -283
- package/lib-module/Radio/RadioButton.js +0 -184
- package/lib-module/Radio/RadioGroup.js +0 -255
- package/lib-module/Radio/RadioInput.js +0 -50
- package/lib-module/Radio/RadioInput.native.js +0 -5
- package/lib-module/Radio/index.js +0 -3
- package/lib-module/RadioCard/RadioCard.js +0 -211
- package/lib-module/RadioCard/RadioCardGroup.js +0 -257
- package/lib-module/RadioCard/index.js +0 -3
- package/lib-module/Responsive/Responsive.js +0 -65
- package/lib-module/Responsive/ResponsiveProp.js +0 -39
- package/lib-module/Responsive/ResponsiveWithMediaQueryStyleSheet.js +0 -68
- package/lib-module/Responsive/index.js +0 -2
- package/lib-module/Search/Search.js +0 -242
- package/lib-module/Search/dictionary.js +0 -12
- package/lib-module/Search/index.js +0 -2
- package/lib-module/Select/Group.js +0 -24
- package/lib-module/Select/Group.native.js +0 -16
- package/lib-module/Select/Item.js +0 -23
- package/lib-module/Select/Item.native.js +0 -2
- package/lib-module/Select/Picker.js +0 -97
- package/lib-module/Select/Picker.native.js +0 -120
- package/lib-module/Select/Select.js +0 -337
- package/lib-module/Select/constants.js +0 -5
- package/lib-module/Select/index.js +0 -6
- package/lib-module/SideNav/Item.js +0 -143
- package/lib-module/SideNav/ItemContent.js +0 -50
- package/lib-module/SideNav/ItemsGroup.js +0 -121
- package/lib-module/SideNav/SideNav.js +0 -131
- package/lib-module/SideNav/index.js +0 -1
- package/lib-module/Skeleton/Skeleton.js +0 -177
- package/lib-module/Skeleton/index.js +0 -2
- package/lib-module/Skeleton/skeleton.constant.js +0 -2
- package/lib-module/Skeleton/skeletonWebAnimation.js +0 -14
- package/lib-module/Skeleton/useSkeletonNativeAnimation.js +0 -28
- package/lib-module/SkipLink/SkipLink.js +0 -190
- package/lib-module/SkipLink/index.js +0 -2
- package/lib-module/Spacer/Spacer.js +0 -95
- package/lib-module/Spacer/index.js +0 -2
- package/lib-module/StackView/StackView.js +0 -126
- package/lib-module/StackView/StackWrap.js +0 -51
- package/lib-module/StackView/StackWrap.native.js +0 -4
- package/lib-module/StackView/StackWrapBox.js +0 -114
- package/lib-module/StackView/StackWrapGap.js +0 -61
- package/lib-module/StackView/common.js +0 -35
- package/lib-module/StackView/getStackedContent.js +0 -123
- package/lib-module/StackView/index.js +0 -5
- package/lib-module/Status/Status.js +0 -167
- package/lib-module/Status/index.js +0 -2
- package/lib-module/StepTracker/Step.js +0 -265
- package/lib-module/StepTracker/StepTracker.js +0 -208
- package/lib-module/StepTracker/dictionary.js +0 -30
- package/lib-module/StepTracker/index.js +0 -2
- package/lib-module/TabBar/TabBar.js +0 -125
- package/lib-module/TabBar/TabBarItem.js +0 -177
- package/lib-module/TabBar/index.js +0 -2
- package/lib-module/Tabs/Tabs.js +0 -179
- package/lib-module/Tabs/TabsItem.js +0 -239
- package/lib-module/Tabs/index.js +0 -2
- package/lib-module/Tags/Tags.js +0 -245
- package/lib-module/Tags/index.js +0 -2
- package/lib-module/TextInput/TextArea.js +0 -97
- package/lib-module/TextInput/TextInput.js +0 -80
- package/lib-module/TextInput/TextInputBase.js +0 -436
- package/lib-module/TextInput/dictionary.js +0 -12
- package/lib-module/TextInput/index.js +0 -3
- package/lib-module/TextInput/propTypes.js +0 -34
- package/lib-module/ThemeProvider/ThemeProvider.js +0 -84
- package/lib-module/ThemeProvider/index.js +0 -7
- package/lib-module/ThemeProvider/useResponsiveThemeTokens.js +0 -81
- package/lib-module/ThemeProvider/useSetTheme.js +0 -24
- package/lib-module/ThemeProvider/useTheme.js +0 -11
- package/lib-module/ThemeProvider/useThemeTokens.js +0 -109
- package/lib-module/ThemeProvider/utils/index.js +0 -2
- package/lib-module/ThemeProvider/utils/styles.js +0 -198
- package/lib-module/ThemeProvider/utils/theme-tokens.js +0 -160
- package/lib-module/Timeline/Timeline.js +0 -168
- package/lib-module/Timeline/index.js +0 -2
- package/lib-module/ToggleSwitch/ToggleSwitch.js +0 -280
- package/lib-module/ToggleSwitch/ToggleSwitchGroup.js +0 -208
- package/lib-module/ToggleSwitch/index.js +0 -3
- package/lib-module/Tooltip/Backdrop.js +0 -50
- package/lib-module/Tooltip/Backdrop.native.js +0 -41
- package/lib-module/Tooltip/Tooltip.js +0 -280
- package/lib-module/Tooltip/Tooltip.native.js +0 -328
- package/lib-module/Tooltip/dictionary.js +0 -8
- package/lib-module/Tooltip/getTooltipPosition.js +0 -170
- package/lib-module/Tooltip/index.js +0 -5
- package/lib-module/Tooltip/shared.js +0 -36
- package/lib-module/TooltipButton/TooltipButton.js +0 -90
- package/lib-module/TooltipButton/index.js +0 -2
- package/lib-module/Typography/Typography.js +0 -254
- package/lib-module/Typography/index.js +0 -2
- package/lib-module/Validator/Validator.js +0 -222
- package/lib-module/Validator/index.js +0 -2
- package/lib-module/ViewportProvider/ViewportProvider.js +0 -27
- package/lib-module/ViewportProvider/index.js +0 -3
- package/lib-module/ViewportProvider/useViewport.js +0 -3
- package/lib-module/ViewportProvider/useViewportListener.js +0 -37
- package/lib-module/index.js +0 -76
- package/lib-module/server.js +0 -4
- package/lib-module/utils/BaseView/BaseView.js +0 -42
- package/lib-module/utils/BaseView/BaseView.native.js +0 -5
- package/lib-module/utils/BaseView/index.js +0 -2
- package/lib-module/utils/a11y/index.js +0 -2
- package/lib-module/utils/a11y/semantics.js +0 -144
- package/lib-module/utils/a11y/textSize.js +0 -35
- package/lib-module/utils/animation/index.js +0 -2
- package/lib-module/utils/animation/useVerticalExpandAnimation.js +0 -86
- package/lib-module/utils/children.js +0 -117
- package/lib-module/utils/containUniqueFields.js +0 -24
- package/lib-module/utils/convertFromMegaByteToByte.js +0 -10
- package/lib-module/utils/floating-ui/index.js +0 -1
- package/lib-module/utils/floating-ui/index.native.js +0 -1
- package/lib-module/utils/formatImageSource.js +0 -27
- package/lib-module/utils/hasOwnProperty.js +0 -11
- package/lib-module/utils/htmlAttrs.js +0 -23
- package/lib-module/utils/index.js +0 -25
- package/lib-module/utils/info/index.js +0 -8
- package/lib-module/utils/info/platform/index.js +0 -14
- package/lib-module/utils/info/platform/platform.android.js +0 -1
- package/lib-module/utils/info/platform/platform.ios.js +0 -1
- package/lib-module/utils/info/platform/platform.js +0 -1
- package/lib-module/utils/info/platform/platform.native.js +0 -4
- package/lib-module/utils/info/versions.js +0 -6
- package/lib-module/utils/input.js +0 -185
- package/lib-module/utils/pressability.js +0 -112
- package/lib-module/utils/props/a11yProps.js +0 -310
- package/lib-module/utils/props/clickProps.js +0 -25
- package/lib-module/utils/props/componentPropType.js +0 -50
- package/lib-module/utils/props/copyPropTypes.js +0 -2
- package/lib-module/utils/props/getPropSelector.js +0 -52
- package/lib-module/utils/props/handlerProps.js +0 -105
- package/lib-module/utils/props/hrefAttrsProp.js +0 -33
- package/lib-module/utils/props/index.js +0 -19
- package/lib-module/utils/props/inputSupportsProps.js +0 -68
- package/lib-module/utils/props/linkProps.js +0 -43
- package/lib-module/utils/props/paddingProp.js +0 -9
- package/lib-module/utils/props/pressProps.js +0 -42
- package/lib-module/utils/props/rectProp.js +0 -9
- package/lib-module/utils/props/responsiveProps.js +0 -28
- package/lib-module/utils/props/selectSystemProps.js +0 -23
- package/lib-module/utils/props/spacingProps.js +0 -57
- package/lib-module/utils/props/textInputProps.js +0 -188
- package/lib-module/utils/props/textProps.js +0 -61
- package/lib-module/utils/props/tokens.js +0 -130
- package/lib-module/utils/props/variantProp.js +0 -18
- package/lib-module/utils/props/viewProps.js +0 -21
- package/lib-module/utils/ssr-media-query/create-stylesheet/create-stylesheet-mobile.js +0 -48
- package/lib-module/utils/ssr-media-query/create-stylesheet/index.android.js +0 -2
- package/lib-module/utils/ssr-media-query/create-stylesheet/index.ios.js +0 -2
- package/lib-module/utils/ssr-media-query/create-stylesheet/index.js +0 -36
- package/lib-module/utils/ssr-media-query/hash.js +0 -13
- package/lib-module/utils/ssr-media-query/index.js +0 -6
- package/lib-module/utils/ssr-media-query/utils/common.js +0 -33
- package/lib-module/utils/ssr-media-query/utils/create-declaration-block.js +0 -16
- package/lib-module/utils/ssr-media-query/utils/create-media-query-styles.js +0 -60
- package/lib-module/utils/ssr-media-query/utils/hyphenate-style-name.js +0 -12
- package/lib-module/utils/ssr-media-query/utils/inject.js +0 -39
- package/lib-module/utils/ssr.js +0 -142
- package/lib-module/utils/transformGradient.js +0 -15
- package/lib-module/utils/useCopy.js +0 -42
- package/lib-module/utils/useHash.js +0 -41
- package/lib-module/utils/useHash.native.js +0 -6
- package/lib-module/utils/useOverlaidPosition.js +0 -214
- package/lib-module/utils/useResponsiveProp.js +0 -45
- package/lib-module/utils/useSafeLayoutEffect.js +0 -28
- package/lib-module/utils/useScrollBlocking.js +0 -51
- package/lib-module/utils/useScrollBlocking.native.js +0 -2
- package/lib-module/utils/useSpacingScale.js +0 -123
- package/lib-module/utils/useUniqueId.js +0 -11
- package/lib-module/utils/withLinkRouter.js +0 -84
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_COPY = 'en';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Extract translations from a keyed dictionary for a given language.
|
|
5
|
-
* Returns a getter.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* const getCopy = useCopy({
|
|
9
|
-
* copy: 'en',
|
|
10
|
-
* dictionary: {
|
|
11
|
-
* en: { label: 'english label' },
|
|
12
|
-
* fr: { label: 'french label' }
|
|
13
|
-
* }
|
|
14
|
-
* })
|
|
15
|
-
*
|
|
16
|
-
* getCopy('label') => 'english label'
|
|
17
|
-
*
|
|
18
|
-
* @description The entire dictionary may be overridden by simply passing a single language object as `copy`:
|
|
19
|
-
* @example
|
|
20
|
-
* const getCopy = useCopy({
|
|
21
|
-
* copy: { label: 'custom label' }
|
|
22
|
-
* })
|
|
23
|
-
*
|
|
24
|
-
* getCopy('label') => 'custom label'
|
|
25
|
-
*
|
|
26
|
-
* @param {object} [dictionary]
|
|
27
|
-
* @param {'en'|'fr'|object} copy - language
|
|
28
|
-
* @return {function(string): string}
|
|
29
|
-
*/
|
|
30
|
-
function useCopy(_ref) {
|
|
31
|
-
let {
|
|
32
|
-
dictionary,
|
|
33
|
-
copy = DEFAULT_COPY
|
|
34
|
-
} = _ref;
|
|
35
|
-
if (typeof copy === 'string') {
|
|
36
|
-
return key => key ? dictionary[copy][key] : dictionary[copy];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// support overriding the entire copy dictionary with an object for a single language
|
|
40
|
-
return key => copy[key];
|
|
41
|
-
}
|
|
42
|
-
export default useCopy;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
const doAction = (action, event) => {
|
|
3
|
-
var _window, _window$location;
|
|
4
|
-
return typeof action === 'function' && action((_window = window) === null || _window === void 0 ? void 0 : (_window$location = _window.location) === null || _window$location === void 0 ? void 0 : _window$location.hash, event);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {import('react').SyntheticEvent} SyntheticEvent
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Calls a function (passing it the current hash) based on the current hash state on mount,
|
|
13
|
-
* and binds it to call it again any time the hash changes.
|
|
14
|
-
*
|
|
15
|
-
* Consider using `useCallback` on the function to minimise adding and removing of event listeners.
|
|
16
|
-
*
|
|
17
|
-
* On Native, this is replaced with a harmless no-op function as there is no direct equivalent.
|
|
18
|
-
*
|
|
19
|
-
* @param {(hash: string, event?: SyntheticEvent) => void} action - a function to act on the current hash on load and when it changes
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
const useHash = function (action) {
|
|
23
|
-
let isReady = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
24
|
-
const [isDone, setIsDone] = useState(false);
|
|
25
|
-
// Do the action just once when ready after component mount, from hash on page load
|
|
26
|
-
const isToDo = isReady && !isDone;
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (isToDo) {
|
|
29
|
-
setIsDone(true);
|
|
30
|
-
doAction(action);
|
|
31
|
-
}
|
|
32
|
-
}, [isToDo, action]);
|
|
33
|
-
|
|
34
|
-
// Bind the action for each hash change; do re-bind if the function changes.
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
const handleChange = event => doAction(action, event);
|
|
37
|
-
window.addEventListener('hashchange', handleChange);
|
|
38
|
-
return () => window.removeEventListener('hashchange', handleChange);
|
|
39
|
-
}, [action]);
|
|
40
|
-
};
|
|
41
|
-
export default useHash;
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import Dimensions from "react-native-web/dist/exports/Dimensions";
|
|
3
|
-
import Platform from "react-native-web/dist/exports/Platform";
|
|
4
|
-
const adjustHorizontalToFit = (initialOffset, windowWidth, sourceWidth) => {
|
|
5
|
-
const offset = Math.max(0, initialOffset);
|
|
6
|
-
const otherEdgeOverflow = Math.max(0, offset + sourceWidth - windowWidth);
|
|
7
|
-
const tooWideBy = Math.max(0, otherEdgeOverflow - offset);
|
|
8
|
-
const adjusted = {
|
|
9
|
-
offset: Math.max(0, offset - otherEdgeOverflow)
|
|
10
|
-
};
|
|
11
|
-
if (tooWideBy) adjusted.width = Math.max(0, sourceWidth - tooWideBy);
|
|
12
|
-
return adjusted;
|
|
13
|
-
};
|
|
14
|
-
const getPosition = _ref => {
|
|
15
|
-
let {
|
|
16
|
-
edge,
|
|
17
|
-
fromEdge,
|
|
18
|
-
sourceSize
|
|
19
|
-
} = _ref;
|
|
20
|
-
switch (edge) {
|
|
21
|
-
case 'near':
|
|
22
|
-
return fromEdge;
|
|
23
|
-
case 'mid':
|
|
24
|
-
return fromEdge + sourceSize / 2;
|
|
25
|
-
case 'far':
|
|
26
|
-
return fromEdge + sourceSize;
|
|
27
|
-
default:
|
|
28
|
-
return 0;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const getEdgeType = (align, alignSide) => {
|
|
32
|
-
const alignTo = align[alignSide];
|
|
33
|
-
const edge = ['center', 'middle'].includes(alignTo) && 'mid' || (alignSide === alignTo ? 'near' : 'far');
|
|
34
|
-
return edge;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Based on UDS's private getTooltipPosition but generalised.
|
|
39
|
-
*
|
|
40
|
-
* Used for absolute positioning of the tooltip. Since the tooltip is always centered relatively
|
|
41
|
-
* to the source (button) and we have a limited set of positions, an easy and consistent way
|
|
42
|
-
* of positioning it is to check all of the possible positions and pick one that will be rendered
|
|
43
|
-
* within the window bounds. This way we can also rely on the tooltip being actually rendered
|
|
44
|
-
* before it is shown, which makes it account for the width being limiting in styles, custom font
|
|
45
|
-
* rendering, etc.
|
|
46
|
-
*/
|
|
47
|
-
function getOverlaidPosition(_ref2) {
|
|
48
|
-
let {
|
|
49
|
-
sourceLayout,
|
|
50
|
-
targetDimensions,
|
|
51
|
-
windowDimensions,
|
|
52
|
-
offsets = {},
|
|
53
|
-
align
|
|
54
|
-
} = _ref2;
|
|
55
|
-
// Web-only: this will be difficult to mimic on native because there's no global scroll position.
|
|
56
|
-
// TODO: wire something in e.g. a scroll ref accessible from a provider included in Allium provider
|
|
57
|
-
// that can be passed to the appropriate ScrollView?
|
|
58
|
-
const {
|
|
59
|
-
scrollX = 0,
|
|
60
|
-
scrollY = 0
|
|
61
|
-
} = typeof window === 'object' ? window : {};
|
|
62
|
-
|
|
63
|
-
// Will have top, bottom, left and/or right offsets depending on `align`
|
|
64
|
-
const positioning = {};
|
|
65
|
-
if (align.top) positioning.top = getPosition({
|
|
66
|
-
edge: getEdgeType(align, 'top'),
|
|
67
|
-
fromEdge: sourceLayout.y + scrollY + (offsets.vertical ?? 0),
|
|
68
|
-
sourceSize: sourceLayout.height
|
|
69
|
-
});
|
|
70
|
-
if (align.middle) positioning.top = getPosition({
|
|
71
|
-
edge: getEdgeType(align, 'middle'),
|
|
72
|
-
fromEdge: sourceLayout.y + scrollY + (offsets.vertical ?? 0) - targetDimensions.height / 2,
|
|
73
|
-
sourceSize: sourceLayout.height
|
|
74
|
-
});
|
|
75
|
-
if (align.bottom) positioning.bottom = getPosition({
|
|
76
|
-
edge: getEdgeType(align, 'bottom'),
|
|
77
|
-
fromEdge: windowDimensions.height - (sourceLayout.y + scrollY + sourceLayout.height - (offsets.vertical ?? 0)),
|
|
78
|
-
sourceSize: sourceLayout.height
|
|
79
|
-
});
|
|
80
|
-
if (align.left) positioning.left = getPosition({
|
|
81
|
-
edge: getEdgeType(align, 'left'),
|
|
82
|
-
fromEdge: sourceLayout.x + scrollX + (offsets.horizontal ?? 0),
|
|
83
|
-
sourceSize: sourceLayout.width
|
|
84
|
-
});
|
|
85
|
-
if (align.center) positioning.left = getPosition({
|
|
86
|
-
edge: getEdgeType(align, 'center'),
|
|
87
|
-
fromEdge: sourceLayout.x + scrollX + (offsets.horizontal ?? 0) - targetDimensions.width / 2,
|
|
88
|
-
sourceSize: sourceLayout.width
|
|
89
|
-
});
|
|
90
|
-
if (align.right) positioning.right = getPosition({
|
|
91
|
-
edge: getEdgeType(align, 'right'),
|
|
92
|
-
fromEdge: windowDimensions.width - (sourceLayout.x + scrollX + sourceLayout.width - (offsets.horizontal ?? 0)),
|
|
93
|
-
sourceSize: sourceLayout.width
|
|
94
|
-
});
|
|
95
|
-
if (!(align.left && align.right)) {
|
|
96
|
-
// Check if the position and/or width need adjusting to fit on the screen
|
|
97
|
-
const side = align.right ? 'right' : 'left';
|
|
98
|
-
const adjusted = adjustHorizontalToFit(positioning[side], windowDimensions.width, sourceLayout.width);
|
|
99
|
-
if (typeof adjusted.width === 'number') positioning.width = adjusted.width;
|
|
100
|
-
if (typeof adjusted.offset === 'number') {
|
|
101
|
-
positioning[side] = adjusted.offset;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return positioning;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Positions an element in a modal or portal so that it appears tooltip-like below the
|
|
109
|
-
* target element.
|
|
110
|
-
*
|
|
111
|
-
* @TODO - add support for positioning other than 'below' like UDS's tooltip (this is not
|
|
112
|
-
* a small task because UDS's tooltip logic only really works for short text - it might be
|
|
113
|
-
* better to use a third-party library).
|
|
114
|
-
*/
|
|
115
|
-
const useOverlaidPosition = _ref3 => {
|
|
116
|
-
let {
|
|
117
|
-
isShown = false,
|
|
118
|
-
offsets,
|
|
119
|
-
// By default, align the overlaid target's `top` to the bottom of the source, and center horizontally.
|
|
120
|
-
align = {
|
|
121
|
-
center: 'center',
|
|
122
|
-
top: 'bottom'
|
|
123
|
-
}
|
|
124
|
-
} = _ref3;
|
|
125
|
-
// Element in main document flow that the targetRef element is positioned around
|
|
126
|
-
const sourceRef = useRef(null);
|
|
127
|
-
const [sourceLayout, setSourceLayout] = useState(null);
|
|
128
|
-
|
|
129
|
-
// Element in a modal or portal overlay positioned to appear adjacent to sourceRef
|
|
130
|
-
const targetRef = useRef(null);
|
|
131
|
-
const [targetDimensions, setTargetDimensions] = useState(null);
|
|
132
|
-
const [windowDimensions, setWindowDimensions] = useState(null);
|
|
133
|
-
const onTargetLayout = useCallback(_ref4 => {
|
|
134
|
-
let {
|
|
135
|
-
nativeEvent: {
|
|
136
|
-
layout: {
|
|
137
|
-
width,
|
|
138
|
-
height
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
} = _ref4;
|
|
142
|
-
// NOTE: UDS's Tooltip logic injects some additional width to allow for antialiasing etc of text,
|
|
143
|
-
// avoiding adding unnecessary line breaks to text that is slightly wider than it thinks it is.
|
|
144
|
-
// That is probably something specific to text tooltips that doesn't belong in a generic hook.
|
|
145
|
-
setTargetDimensions(previousDimensions => {
|
|
146
|
-
// Re-render on first non-zero width / height: avoid infinite loops on changes, or mispositioning
|
|
147
|
-
// if user scrolls while a slidedown animation is changing the height and recalculating position.
|
|
148
|
-
if (!previousDimensions && width && height) {
|
|
149
|
-
return {
|
|
150
|
-
width,
|
|
151
|
-
height
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
return previousDimensions;
|
|
155
|
-
});
|
|
156
|
-
}, []);
|
|
157
|
-
const readyToShow = Boolean(isShown && sourceRef.current);
|
|
158
|
-
useEffect(() => {
|
|
159
|
-
const handleDimensionsChange = _ref5 => {
|
|
160
|
-
var _sourceRef$current;
|
|
161
|
-
let {
|
|
162
|
-
window
|
|
163
|
-
} = _ref5;
|
|
164
|
-
const measurementFunction = Platform.OS === 'web' ? 'measureInWindow' : 'measure';
|
|
165
|
-
(_sourceRef$current = sourceRef.current) === null || _sourceRef$current === void 0 ? void 0 : _sourceRef$current[measurementFunction]((x, y, width, height) => {
|
|
166
|
-
setWindowDimensions(window);
|
|
167
|
-
setSourceLayout({
|
|
168
|
-
x,
|
|
169
|
-
y,
|
|
170
|
-
width,
|
|
171
|
-
height
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
let subscription;
|
|
176
|
-
const unsubscribe = () => {
|
|
177
|
-
var _subscription;
|
|
178
|
-
if (typeof ((_subscription = subscription) === null || _subscription === void 0 ? void 0 : _subscription.remove) === 'function') {
|
|
179
|
-
// React Native >=0.65.0
|
|
180
|
-
subscription.remove();
|
|
181
|
-
} else if (typeof Dimensions.remove === 'function') {
|
|
182
|
-
// React Native <0.65.0
|
|
183
|
-
Dimensions.remove('change', handleDimensionsChange);
|
|
184
|
-
}
|
|
185
|
-
setSourceLayout(null);
|
|
186
|
-
setTargetDimensions(null);
|
|
187
|
-
};
|
|
188
|
-
if (readyToShow) {
|
|
189
|
-
subscription = Dimensions.addEventListener('change', handleDimensionsChange);
|
|
190
|
-
handleDimensionsChange({
|
|
191
|
-
window: Dimensions.get('window')
|
|
192
|
-
});
|
|
193
|
-
} else {
|
|
194
|
-
unsubscribe();
|
|
195
|
-
}
|
|
196
|
-
return unsubscribe;
|
|
197
|
-
}, [readyToShow]);
|
|
198
|
-
const isReady = Boolean(isShown && sourceLayout && windowDimensions && targetDimensions);
|
|
199
|
-
const overlaidPosition = isReady ? getOverlaidPosition({
|
|
200
|
-
sourceLayout,
|
|
201
|
-
targetDimensions,
|
|
202
|
-
windowDimensions,
|
|
203
|
-
offsets,
|
|
204
|
-
align
|
|
205
|
-
}) : {};
|
|
206
|
-
return {
|
|
207
|
-
overlaidPosition,
|
|
208
|
-
sourceRef,
|
|
209
|
-
targetRef,
|
|
210
|
-
onTargetLayout,
|
|
211
|
-
isReady
|
|
212
|
-
};
|
|
213
|
-
};
|
|
214
|
-
export default useOverlaidPosition;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { viewports } from '@telus-uds/system-constants';
|
|
2
|
-
import { useViewport } from '../ViewportProvider';
|
|
3
|
-
import hasOwnProperty from './hasOwnProperty';
|
|
4
|
-
const hasResponsiveProperties = objectProp => viewports.keys.some(key => hasOwnProperty(objectProp, key));
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Resolves a prop which may be a responsive object with keys for viewports.
|
|
8
|
-
*
|
|
9
|
-
* Used internally in useResponsiveProp - see that for more details.
|
|
10
|
-
*
|
|
11
|
-
* @param {*} prop
|
|
12
|
-
* @param {"xs"|"sm"|"md"|"lg"|"xl"} viewport
|
|
13
|
-
* @param {*} [defaultValue]
|
|
14
|
-
* @returns {*}
|
|
15
|
-
*/
|
|
16
|
-
export const resolveResponsiveProp = (prop, viewport, defaultValue) => {
|
|
17
|
-
if (prop === undefined) return defaultValue;
|
|
18
|
-
if (!prop || typeof prop !== 'object' || !hasResponsiveProperties(prop)) return prop;
|
|
19
|
-
const value = viewports.keys.includes(viewport) ?
|
|
20
|
-
// If there's a current viewport, return the closest match at or below it
|
|
21
|
-
viewports.inherit(prop)[viewport] :
|
|
22
|
-
// If no current viewport is available, default to smallest viewport
|
|
23
|
-
prop[viewports.keys.find(key => hasOwnProperty(prop, key))];
|
|
24
|
-
return value === undefined ? defaultValue : value;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Takes any value and, if that value is a responsive prop (an object with one or more
|
|
29
|
-
* keys matching system viewport names), returns the value corresponding to the largest
|
|
30
|
-
* viewport key smaller than the current screen's viewport.
|
|
31
|
-
*
|
|
32
|
-
* For example, if passed `{ sm: 4, lg: 8 }`, it will return 8 on `xl` and `lg` viewports,
|
|
33
|
-
* 4 on `md` and `sm` viewports, and `undefined` (or a provided `defaultValue`) on `xs` viewports.
|
|
34
|
-
*
|
|
35
|
-
* To generate propTypes for responsive props, see `responsiveProps` in `./utils/props/responsiveProps.js`.
|
|
36
|
-
*
|
|
37
|
-
* @param {*} prop - any value which may be an object with viewport keys
|
|
38
|
-
* @param {*} [defaultValue] - default value to provide if no matches found for the current viewport
|
|
39
|
-
* @returns {*}
|
|
40
|
-
*/
|
|
41
|
-
const useResponsiveProp = (prop, defaultValue) => {
|
|
42
|
-
const viewport = useViewport();
|
|
43
|
-
return resolveResponsiveProp(prop, viewport, defaultValue);
|
|
44
|
-
};
|
|
45
|
-
export default useResponsiveProp;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect, useCallback } from 'react';
|
|
2
|
-
import { useHydrationContext } from '../BaseProvider/HydrationContext';
|
|
3
|
-
const isSSR = typeof window === 'undefined';
|
|
4
|
-
const noop = () => {};
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* useSafeLayoutEffect is a alternative to useLayoutEffect that avoids SSR hydration problems:
|
|
8
|
-
* - In a client-side render, it uses useLayoutEffect to avoid flashing the pre-render UI to the user.
|
|
9
|
-
* - During hydration from SSR, the provided function is skipped to avoid mismatches from server content.
|
|
10
|
-
* - In SSR, it is a no-op function to avoid warnings about using useLayoutEffect in SSR
|
|
11
|
-
*/
|
|
12
|
-
const useSafeLayoutEffect = isSSR ? noop // avoid React's fussy warnings by ensuring to never call useLayoutEffect on server
|
|
13
|
-
: function (fn) {
|
|
14
|
-
let deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
15
|
-
const isHydrating = useHydrationContext();
|
|
16
|
-
|
|
17
|
-
// Callback updates and effect re-runs when deps array content changes, like useEffect.
|
|
18
|
-
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
19
|
-
const callback = useCallback(fn, deps);
|
|
20
|
-
useLayoutEffect(() => {
|
|
21
|
-
// Do nothing before hydrating server-generated content, like useEffect. When hydration completes,
|
|
22
|
-
// useHydrationContext provides false, re-rendering this hook and re-running the effect.
|
|
23
|
-
if (isHydrating) return noop;
|
|
24
|
-
// If there's no hydration in progress, behave like useLayoutEffect.
|
|
25
|
-
return callback();
|
|
26
|
-
}, [isHydrating, callback]);
|
|
27
|
-
};
|
|
28
|
-
export default useSafeLayoutEffect;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
-
const addScrollBlocking = (preventScrolling, stopPropagation, ref) => {
|
|
3
|
-
var _ref$current;
|
|
4
|
-
document.body.addEventListener('touchmove', preventScrolling, {
|
|
5
|
-
passive: false
|
|
6
|
-
});
|
|
7
|
-
(_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.addEventListener('touchmove', stopPropagation);
|
|
8
|
-
document.body.style.overflow = 'hidden';
|
|
9
|
-
};
|
|
10
|
-
const removeScrollBlocking = (preventScrolling, stopPropagation, ref) => {
|
|
11
|
-
var _ref$current2;
|
|
12
|
-
document.body.removeEventListener('touchmove', preventScrolling);
|
|
13
|
-
(_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.removeEventListener('touchmove', stopPropagation);
|
|
14
|
-
document.body.style.overflow = 'inherit';
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Disables scrolling when passed `true` or an array where all items are `true`.
|
|
19
|
-
*
|
|
20
|
-
* Returns an optional callback ref. Pass this to an element if it or its children
|
|
21
|
-
* should allow touch-based scrolling within that element's bounds.
|
|
22
|
-
*
|
|
23
|
-
* @param {boolean | boolean[]} conditionProps
|
|
24
|
-
* @returns
|
|
25
|
-
*/
|
|
26
|
-
const useScrollBlocking = conditionProps => {
|
|
27
|
-
// useRef refs are null on first render and don't trigger a re-render when they get their
|
|
28
|
-
// element. Force re-run when ref mounts to ensure the stopPropagation listener is attached.
|
|
29
|
-
const ref = useRef();
|
|
30
|
-
const [refIsMounted, setRefIsMounted] = useState(false);
|
|
31
|
-
const callbackRef = useCallback(element => {
|
|
32
|
-
ref.current = element;
|
|
33
|
-
setRefIsMounted(Boolean(element));
|
|
34
|
-
}, []);
|
|
35
|
-
const conditionsMet = Array.isArray(conditionProps) ? conditionProps.every(condition => condition) : Boolean(conditionProps);
|
|
36
|
-
const preventScrolling = useCallback(event => event.preventDefault(), []);
|
|
37
|
-
const stopPropagation = useCallback(event => event.stopPropagation(), []);
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
const cleanup = () => removeScrollBlocking(preventScrolling, stopPropagation, ref);
|
|
40
|
-
if (conditionsMet) {
|
|
41
|
-
addScrollBlocking(preventScrolling, stopPropagation, ref);
|
|
42
|
-
} else {
|
|
43
|
-
cleanup();
|
|
44
|
-
}
|
|
45
|
-
return cleanup;
|
|
46
|
-
// preventScrolling and stopPropagation are stable callbacks with no deps, so this
|
|
47
|
-
// will re-run when conditionsMet or refIsMounted flip between true and false.
|
|
48
|
-
}, [preventScrolling, conditionsMet, stopPropagation, refIsMounted]);
|
|
49
|
-
return callbackRef;
|
|
50
|
-
};
|
|
51
|
-
export default useScrollBlocking;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { useViewport } from '../ViewportProvider';
|
|
2
|
-
import { useThemeTokens } from '../ThemeProvider';
|
|
3
|
-
import { resolveResponsiveProp } from './useResponsiveProp';
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {import('@telus-uds/system-constants/viewports').Viewport} Viewport
|
|
6
|
-
* @typedef {import('./props/spacingProps.js').SpacingValue} SpacingValue
|
|
7
|
-
* @typedef {import('./props/spacingProps.js').SpacingIndex} SpacingIndex
|
|
8
|
-
* @typedef {import('./props/spacingProps.js').SpacingObject} SpacingObject
|
|
9
|
-
* @typedef {import('./props/spacingProps.js').SpacingOptions} SpacingOptions
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const resolveSpacingOptions = space => {
|
|
13
|
-
if (!(space !== null && space !== void 0 && space.options)) return {};
|
|
14
|
-
const {
|
|
15
|
-
size,
|
|
16
|
-
variant,
|
|
17
|
-
subtract = 0
|
|
18
|
-
} = space.options;
|
|
19
|
-
const overridden = typeof size === 'number';
|
|
20
|
-
|
|
21
|
-
// Might need an option that adapts the size value by current user's system font scale, so that
|
|
22
|
-
// meaningful spacing between items doesn't disappear on the highest a11y font scale settings.
|
|
23
|
-
// https://github.com/telus/universal-design-system/issues/583
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
tokens: {
|
|
27
|
-
size
|
|
28
|
-
},
|
|
29
|
-
variant,
|
|
30
|
-
overridden,
|
|
31
|
-
subtract
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Pass a {@link SpacingValue}, which is one of:
|
|
37
|
-
*
|
|
38
|
-
* - A number 0-11 ({@link SpacingIndex}) pointing to an index on the theme's spacing scale
|
|
39
|
-
* - Or, an object ({@link SpacingObject}), with optional properties:
|
|
40
|
-
* - `xs`, `sm`, `md`, `lg`, `xl`: {@link SpacingIndex} to apply at or above these specified {@link Viewport}
|
|
41
|
-
* - `options`: an optional {@link SpacingOptions} object, see below
|
|
42
|
-
* - `space`: a {@link SpacingIndex} to apply to all viewports (can be used alongside `options`)
|
|
43
|
-
*
|
|
44
|
-
* ## Example
|
|
45
|
-
*
|
|
46
|
-
* If the theme's spacing scale is `[0, 4, 8, 12, 16, 24, 48]` with no theme rules:
|
|
47
|
-
*
|
|
48
|
-
* - `useSpacingScale(0)` returns `0`
|
|
49
|
-
* - `useSpacingScale(2)` returns `8`
|
|
50
|
-
* - `useSpacingScale({ xs: 3, lg: 4 })` returns `12` at 'xs', 'sm' or 'md' viewports, and `16` at 'lg' or 'xl'.
|
|
51
|
-
*
|
|
52
|
-
* These viewport properties are intended to support case-specific responsive layout changes, for example, where a
|
|
53
|
-
* grid item drops or adds spacing on a particular side at viewports where the parent changes the layout shape.
|
|
54
|
-
*
|
|
55
|
-
* ## Theming
|
|
56
|
-
*
|
|
57
|
-
* A theme's `'spacingScale'` has theme rules and appearances same as components, and may support `viewport`.
|
|
58
|
-
* For example, a theme with the following rule would change index [2] above from `8` to `12` on large viewports:
|
|
59
|
-
*
|
|
60
|
-
* ```json
|
|
61
|
-
* { if: { space: 2, viewport: ['lg', 'xl'] }, tokens: { size: 12 }}
|
|
62
|
-
* ```
|
|
63
|
-
*
|
|
64
|
-
* Setting responsive spacing in the theme is the preferred way to adapt the aesthetic tightness or looseness of
|
|
65
|
-
* a theme to the available space without changing the shape of the layout itself.
|
|
66
|
-
*
|
|
67
|
-
* ## Options
|
|
68
|
-
*
|
|
69
|
-
* Space values passed as objects may have an `options` key, with the following optional properties:
|
|
70
|
-
*
|
|
71
|
-
* - `variant`: Themes may choose to have spacing scale variants, same as variants in component themes.
|
|
72
|
-
* For example, if a theme rule contains `{ if: { space: 2, compact: true }, tokens: { size: 6 }}`,
|
|
73
|
-
* this tighter spacing can be accessed with:
|
|
74
|
-
*
|
|
75
|
-
* ```jsx
|
|
76
|
-
* const compactSize = useSpacingScale({ space: 2, options: { variant: { compact: true }}})`
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* - `subtract`: Sometimes on-brand spacing needs to be reduced by another value to achieve an on-brand result.
|
|
80
|
-
* For example, a component with a variable border may want to subtract its border width from its padding so
|
|
81
|
-
* the total distance from content edge to bounding box is a valid theme value, regardless of border width:
|
|
82
|
-
*
|
|
83
|
-
* ```jsx
|
|
84
|
-
* const padding = useSpacingScale({ space: 2, options: { subtract: themeTokens.borderWidth }})
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
|
-
* - `size`: In exceptional cases, the theme's spacing scale may be bypassed by passing a `size` option.
|
|
88
|
-
* This can result in layouts that may be rejected for being off-brand so should only be used as a
|
|
89
|
-
* last resort for fixing layout problems (e.g. when working around non-branded embedded content).
|
|
90
|
-
* Where possible, fixing layout issues using a spacing scale value and the `subtract` option is preferred.
|
|
91
|
-
*
|
|
92
|
-
* ```jsx
|
|
93
|
-
* // Comments should be included when `size` is used, stating why this off-brand size is needed
|
|
94
|
-
* const iframeOffset = useSpacingScale({ options: { size: 13 }})`
|
|
95
|
-
* ```
|
|
96
|
-
*
|
|
97
|
-
* ## References
|
|
98
|
-
*
|
|
99
|
-
* `/ADRs/inter-component-spacing/README.md` - ADR on this structure
|
|
100
|
-
*
|
|
101
|
-
* @param {SpacingValue} [spaceValue] - a {@link SpacingIndex} number, or a {@link SpacingObject}
|
|
102
|
-
* @returns {number}
|
|
103
|
-
*/
|
|
104
|
-
const useSpacingScale = spaceValue => {
|
|
105
|
-
// In future, may need to consider window height as well as width, particularly for native apps,
|
|
106
|
-
// e.g. to ensure designs don't look lost on large, tall, not-so-wide portrait screens.
|
|
107
|
-
const viewport = useViewport();
|
|
108
|
-
const {
|
|
109
|
-
tokens,
|
|
110
|
-
variant,
|
|
111
|
-
overridden,
|
|
112
|
-
subtract = 0
|
|
113
|
-
} = resolveSpacingOptions(spaceValue);
|
|
114
|
-
const space = !overridden && ((spaceValue === null || spaceValue === void 0 ? void 0 : spaceValue.space) ?? resolveResponsiveProp(spaceValue, viewport, 0));
|
|
115
|
-
const {
|
|
116
|
-
size
|
|
117
|
-
} = useThemeTokens('spacingScale', tokens, variant, {
|
|
118
|
-
space: typeof space === 'number' ? space : 0,
|
|
119
|
-
viewport
|
|
120
|
-
});
|
|
121
|
-
return Math.max(size - subtract, 0);
|
|
122
|
-
};
|
|
123
|
-
export default useSpacingScale;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
let id = 0;
|
|
3
|
-
function useUniqueId() {
|
|
4
|
-
let prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
5
|
-
const [uniqueId] = useState(() => {
|
|
6
|
-
id += 1;
|
|
7
|
-
return `${prefix}-${id}`;
|
|
8
|
-
});
|
|
9
|
-
return uniqueId;
|
|
10
|
-
}
|
|
11
|
-
export default useUniqueId;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import hasOwnProperty from './hasOwnProperty';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Higher-order component that has no effect unless an additional prop `LinkRouter` is passed.
|
|
7
|
-
* This may be used to provide custom wrappers for integrations with third party libraries.
|
|
8
|
-
*
|
|
9
|
-
* If LinkRouter is passed, LinkRouter is rendered in place of the main component and is passed:
|
|
10
|
-
*
|
|
11
|
-
* - `linkRouterProps`: an optional object passed alongside LinkRouter, for props needed by the wrapper
|
|
12
|
-
* that are not valid props for the wrapped component.
|
|
13
|
-
* - `Component`: automatically provided, the original component to render inside the wrapper.
|
|
14
|
-
* - `ref`: forwarded `ref` passed down to `Component`
|
|
15
|
-
* - All other props passed to the outer component
|
|
16
|
-
*
|
|
17
|
-
* @example A LinkRouter component to be used with link-like components might look like:
|
|
18
|
-
*
|
|
19
|
-
* ```jsx
|
|
20
|
-
* const LinkLinkRouter = React.forwardRef(({ Component, linkRouterProps: { to, options }, href, ...rest }, ref) => {
|
|
21
|
-
* const { href: resolvedHref, onClick } = useSomeRouterHook({ to, href, options })
|
|
22
|
-
* return <Component href={resolvedHref} onPress={onClick} {...rest} />
|
|
23
|
-
* })
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* Any component that takes href and onPress props may then use this wrapper:
|
|
27
|
-
*
|
|
28
|
-
* ```jsx
|
|
29
|
-
* <Link href={href} LinkRouter={LinkLinkRouter} linkRouterProps={{ to, options }}>Some link</Link>
|
|
30
|
-
* <IconButton icon={SomeIcon} LinkRouter={LinkLinkRouter} linkRouterProps={{ to, options }} ref={iconRef} />
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
|
-
const withLinkRouter = Component => {
|
|
35
|
-
const wrappedComponent = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
36
|
-
let {
|
|
37
|
-
LinkRouter,
|
|
38
|
-
linkRouterProps,
|
|
39
|
-
...props
|
|
40
|
-
} = _ref;
|
|
41
|
-
if (!LinkRouter) return /*#__PURE__*/_jsx(Component, {
|
|
42
|
-
...props,
|
|
43
|
-
ref: ref
|
|
44
|
-
});
|
|
45
|
-
return /*#__PURE__*/_jsx(LinkRouter, {
|
|
46
|
-
linkRouterProps: linkRouterProps,
|
|
47
|
-
Component: Component,
|
|
48
|
-
ref: ref,
|
|
49
|
-
...props
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Ensure the returned component has appropriate outer properties set:
|
|
54
|
-
/* eslint-disable-next-line react/forbid-foreign-prop-types */
|
|
55
|
-
const {
|
|
56
|
-
displayName,
|
|
57
|
-
name,
|
|
58
|
-
propTypes,
|
|
59
|
-
...otherProperties
|
|
60
|
-
} = Component;
|
|
61
|
-
|
|
62
|
-
// Apply unique component name as a displayName
|
|
63
|
-
wrappedComponent.displayName = Component.displayName || Component.name;
|
|
64
|
-
|
|
65
|
-
// Apply proptypes including wrapper props - is safely { ...undefined, ...undefined } in prod
|
|
66
|
-
wrappedComponent.propTypes = {
|
|
67
|
-
...Component.propTypes,
|
|
68
|
-
...withLinkRouter.propTypes
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
// Forward any other properties explicitly set e.g. Component.SubComponent
|
|
72
|
-
Object.keys(otherProperties).forEach(key => {
|
|
73
|
-
// Skip internal React properties from wrappedComponent's forwardRef (render, $$typeof, etc)
|
|
74
|
-
if (hasOwnProperty(Component, key) && !hasOwnProperty(wrappedComponent, key)) {
|
|
75
|
-
wrappedComponent[key] = Component[key];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return wrappedComponent;
|
|
79
|
-
};
|
|
80
|
-
withLinkRouter.propTypes = {
|
|
81
|
-
LinkRouter: PropTypes.elementType,
|
|
82
|
-
linkRouterProps: PropTypes.object
|
|
83
|
-
};
|
|
84
|
-
export default withLinkRouter;
|