@telus-uds/components-web 2.44.0 → 3.0.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/.eslintrc.cjs +26 -0
- package/CHANGELOG.md +13 -2
- package/babel.config.cjs +4 -0
- package/jest.config.cjs +29 -0
- package/lib/Badge/Badge.js +21 -29
- package/lib/Badge/index.js +2 -10
- package/lib/BlockQuote/BlockQuote.js +31 -39
- package/lib/BlockQuote/index.js +2 -10
- package/lib/Breadcrumbs/Breadcrumbs.js +39 -49
- package/lib/Breadcrumbs/Item/Item.js +26 -34
- package/lib/Breadcrumbs/index.js +1 -13
- package/lib/Callout/Callout.js +19 -27
- package/lib/Callout/index.js +2 -10
- package/lib/Card/Card.js +44 -54
- package/lib/Card/CardContent.js +17 -25
- package/lib/Card/CardFooter.js +16 -24
- package/lib/Card/index.js +2 -10
- package/lib/Countdown/Countdown.js +34 -42
- package/lib/Countdown/Segment.js +26 -34
- package/lib/Countdown/constants.js +4 -14
- package/lib/Countdown/dictionary.js +2 -9
- package/lib/Countdown/index.js +2 -10
- package/lib/Countdown/types.js +18 -28
- package/lib/Countdown/useCountdown.js +4 -11
- package/lib/DatePicker/CalendarContainer.js +6 -12
- package/lib/DatePicker/DatePicker.js +94 -103
- package/lib/DatePicker/dictionary.js +1 -8
- package/lib/DatePicker/index.js +2 -10
- package/lib/DatePicker/reactDatesCss.js +3 -10
- package/lib/Disclaimer/Disclaimer.js +15 -23
- package/lib/Disclaimer/index.js +1 -13
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +16 -24
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +17 -26
- package/lib/ExpandCollapseMini/index.js +2 -10
- package/lib/Footnote/Footnote.js +85 -95
- package/lib/Footnote/FootnoteLink.js +25 -33
- package/lib/Footnote/dictionary.js +2 -9
- package/lib/Footnote/index.js +4 -12
- package/lib/IconButton/IconButton.js +12 -20
- package/lib/IconButton/index.js +2 -10
- package/lib/Image/Image.js +17 -25
- package/lib/Image/index.js +6 -18
- package/lib/Image/server.js +4 -12
- package/lib/List/List.js +2 -9
- package/lib/List/ListItem.js +10 -18
- package/lib/List/index.js +4 -12
- package/lib/NavigationBar/NavigationBar.js +51 -59
- package/lib/NavigationBar/NavigationItem.js +19 -27
- package/lib/NavigationBar/NavigationSubMenu.js +34 -40
- package/lib/NavigationBar/collapseItems.js +1 -11
- package/lib/NavigationBar/index.js +4 -12
- package/lib/NavigationBar/resolveItemSelection.js +1 -8
- package/lib/OptimizeImage/OptimizeImage.js +26 -34
- package/lib/OptimizeImage/index.js +2 -10
- package/lib/OptimizeImage/utils/getFallbackUrl.js +3 -10
- package/lib/OptimizeImage/utils/getImageUrls.js +9 -16
- package/lib/OptimizeImage/utils/getOptimizedUrl.js +3 -10
- package/lib/OptimizeImage/utils/hasWebpSupport.js +1 -7
- package/lib/OptimizeImage/utils/index.js +5 -34
- package/lib/OptimizeImage/utils/isSvgUrl.js +1 -7
- package/lib/OrderedList/Item.js +28 -36
- package/lib/OrderedList/ItemBase.js +8 -16
- package/lib/OrderedList/OrderedList.js +22 -30
- package/lib/OrderedList/OrderedListBase.js +12 -20
- package/lib/OrderedList/constants.js +1 -8
- package/lib/OrderedList/index.js +4 -12
- package/lib/Paragraph/Paragraph.js +22 -30
- package/lib/Paragraph/index.js +2 -10
- package/lib/PreviewCard/AuthorDate.js +17 -21
- package/lib/PreviewCard/PreviewCard.js +40 -49
- package/lib/PreviewCard/index.js +2 -10
- package/lib/PriceLockup/PriceLockup.js +56 -64
- package/lib/PriceLockup/index.js +2 -10
- package/lib/PriceLockup/tokens.js +2 -9
- package/lib/Progress/ProgressBar.js +17 -24
- package/lib/Progress/index.js +4 -12
- package/lib/QuantitySelector/QuantitySelector.js +55 -63
- package/lib/QuantitySelector/SideButton.js +15 -23
- package/lib/QuantitySelector/dictionary.js +2 -9
- package/lib/QuantitySelector/index.js +2 -10
- package/lib/QuantitySelector/styles.js +4 -13
- package/lib/ResponsiveImage/ResponsiveImage.js +29 -37
- package/lib/ResponsiveImage/index.js +2 -10
- package/lib/Ribbon/Ribbon.js +22 -30
- package/lib/Ribbon/index.js +2 -10
- package/lib/SkeletonProvider/SkeletonImage.js +14 -22
- package/lib/SkeletonProvider/SkeletonProvider.js +17 -25
- package/lib/SkeletonProvider/SkeletonTypography.js +14 -22
- package/lib/SkeletonProvider/index.js +2 -10
- package/lib/Span/Span.js +23 -31
- package/lib/Span/index.js +2 -10
- package/lib/Spinner/Spinner.js +43 -51
- package/lib/Spinner/SpinnerContent.js +21 -29
- package/lib/Spinner/constants.js +4 -14
- package/lib/Spinner/index.js +2 -10
- package/lib/StoryCard/StoryCard.js +40 -49
- package/lib/StoryCard/index.js +2 -10
- package/lib/Table/Body.js +7 -15
- package/lib/Table/Cell.js +28 -38
- package/lib/Table/Header.js +11 -19
- package/lib/Table/Row.js +8 -16
- package/lib/Table/SubHeading.js +10 -18
- package/lib/Table/Table.js +26 -35
- package/lib/Table/index.js +12 -20
- package/lib/TermsAndConditions/ExpandCollapse.js +22 -30
- package/lib/TermsAndConditions/TermsAndConditions.js +52 -60
- package/lib/TermsAndConditions/dictionary.js +2 -9
- package/lib/TermsAndConditions/index.js +1 -13
- package/lib/Testimonial/Testimonial.js +37 -45
- package/lib/Testimonial/index.js +2 -10
- package/lib/Toast/Toast.js +32 -42
- package/lib/Toast/index.js +2 -10
- package/lib/Video/ControlBar/ControlBar.js +73 -81
- package/lib/Video/ControlBar/Controls/VideoButton/VideoButton.js +16 -24
- package/lib/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +27 -35
- package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +27 -36
- package/lib/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +30 -38
- package/lib/Video/MiddleControlButton/MiddleControlButton.js +16 -24
- package/lib/Video/Video.js +74 -83
- package/lib/Video/index.js +2 -10
- package/lib/Video/videoText.js +1 -8
- package/lib/VideoPicker/VideoPicker.js +43 -53
- package/lib/VideoPicker/VideoPickerPlayer.js +17 -25
- package/lib/VideoPicker/VideoPickerThumbnail.js +38 -46
- package/lib/VideoPicker/VideoSlider.js +17 -26
- package/lib/VideoPicker/index.js +2 -10
- package/lib/VideoPicker/videoPropType.js +9 -18
- package/lib/WaffleGrid/WaffleGrid.js +33 -43
- package/lib/WaffleGrid/index.js +2 -10
- package/lib/WebVideo/WebVideo.js +42 -52
- package/lib/WebVideo/index.js +2 -10
- package/lib/WebVideo/utils/index.js +3 -11
- package/lib/baseExports.js +18 -431
- package/lib/index.js +38 -323
- package/lib/server.js +4 -12
- package/lib/shared/ConditionalWrapper/ConditionalWrapper.js +9 -17
- package/lib/shared/ConditionalWrapper/index.js +2 -10
- package/lib/shared/FullBleedContent/FullBleedContent.js +21 -29
- package/lib/shared/FullBleedContent/getFullBleedBorderRadius.js +1 -8
- package/lib/shared/FullBleedContent/index.js +4 -24
- package/lib/shared/FullBleedContent/useFullBleedContentProps.js +4 -11
- package/lib/shared/VideoSplash/SplashButton/SplashButton.js +19 -27
- package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +27 -35
- package/lib/shared/VideoSplash/VideoSplash.js +24 -32
- package/lib/shared/VideoSplash/helpers.js +5 -14
- package/lib/utils/index.js +10 -75
- package/lib/utils/isElementFocusable.js +1 -8
- package/lib/utils/logger.js +6 -15
- package/lib/utils/media.js +5 -11
- package/lib/utils/renderStructuredContent.js +8 -15
- package/lib/utils/ssr.js +5 -12
- package/lib/utils/theming/get-theme-from-server.js +2 -10
- package/lib/utils/theming/with-client-theme.js +9 -17
- package/lib/utils/theming/with-server-theme.js +11 -19
- package/lib/utils/transforms.js +3 -11
- package/lib/utils/useOverlaidPosition.js +15 -23
- package/lib/utils/useTypographyTheme.js +6 -13
- package/package.json +18 -20
- package/src/Card/Card.jsx +2 -2
- package/src/DatePicker/DatePicker.jsx +1 -2
- package/src/PreviewCard/AuthorDate.jsx +5 -3
- package/src/utils/logger.js +2 -2
- package/lib-module/Badge/Badge.js +0 -121
- package/lib-module/Badge/index.js +0 -2
- package/lib-module/BlockQuote/BlockQuote.js +0 -204
- package/lib-module/BlockQuote/index.js +0 -2
- package/lib-module/Breadcrumbs/Breadcrumbs.js +0 -250
- package/lib-module/Breadcrumbs/Item/Item.js +0 -175
- package/lib-module/Breadcrumbs/index.js +0 -1
- package/lib-module/Callout/Callout.js +0 -135
- package/lib-module/Callout/index.js +0 -2
- package/lib-module/Card/Card.js +0 -251
- package/lib-module/Card/CardContent.js +0 -90
- package/lib-module/Card/CardFooter.js +0 -78
- package/lib-module/Card/index.js +0 -2
- package/lib-module/Countdown/Countdown.js +0 -169
- package/lib-module/Countdown/Segment.js +0 -96
- package/lib-module/Countdown/constants.js +0 -4
- package/lib-module/Countdown/dictionary.js +0 -22
- package/lib-module/Countdown/index.js +0 -2
- package/lib-module/Countdown/types.js +0 -24
- package/lib-module/Countdown/useCountdown.js +0 -26
- package/lib-module/DatePicker/CalendarContainer.js +0 -208
- package/lib-module/DatePicker/DatePicker.js +0 -519
- package/lib-module/DatePicker/dictionary.js +0 -119
- package/lib-module/DatePicker/index.js +0 -2
- package/lib-module/DatePicker/reactDatesCss.js +0 -3
- package/lib-module/Disclaimer/Disclaimer.js +0 -54
- package/lib-module/Disclaimer/index.js +0 -1
- package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +0 -73
- package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +0 -117
- package/lib-module/ExpandCollapseMini/index.js +0 -2
- package/lib-module/Footnote/Footnote.js +0 -632
- package/lib-module/Footnote/FootnoteLink.js +0 -118
- package/lib-module/Footnote/dictionary.js +0 -12
- package/lib-module/Footnote/index.js +0 -4
- package/lib-module/IconButton/IconButton.js +0 -55
- package/lib-module/IconButton/index.js +0 -2
- package/lib-module/Image/Image.js +0 -83
- package/lib-module/Image/index.js +0 -9
- package/lib-module/Image/server.js +0 -4
- package/lib-module/List/List.js +0 -2
- package/lib-module/List/ListItem.js +0 -28
- package/lib-module/List/index.js +0 -4
- package/lib-module/NavigationBar/NavigationBar.js +0 -224
- package/lib-module/NavigationBar/NavigationItem.js +0 -87
- package/lib-module/NavigationBar/NavigationSubMenu.js +0 -162
- package/lib-module/NavigationBar/collapseItems.js +0 -41
- package/lib-module/NavigationBar/index.js +0 -4
- package/lib-module/NavigationBar/resolveItemSelection.js +0 -16
- package/lib-module/OptimizeImage/OptimizeImage.js +0 -92
- package/lib-module/OptimizeImage/index.js +0 -2
- package/lib-module/OptimizeImage/utils/getFallbackUrl.js +0 -7
- package/lib-module/OptimizeImage/utils/getImageUrls.js +0 -12
- package/lib-module/OptimizeImage/utils/getOptimizedUrl.js +0 -17
- package/lib-module/OptimizeImage/utils/hasWebpSupport.js +0 -28
- package/lib-module/OptimizeImage/utils/index.js +0 -5
- package/lib-module/OptimizeImage/utils/isSvgUrl.js +0 -3
- package/lib-module/OrderedList/Item.js +0 -145
- package/lib-module/OrderedList/ItemBase.js +0 -27
- package/lib-module/OrderedList/OrderedList.js +0 -86
- package/lib-module/OrderedList/OrderedListBase.js +0 -45
- package/lib-module/OrderedList/constants.js +0 -2
- package/lib-module/OrderedList/index.js +0 -4
- package/lib-module/Paragraph/Paragraph.js +0 -90
- package/lib-module/Paragraph/index.js +0 -2
- package/lib-module/PreviewCard/AuthorDate.js +0 -57
- package/lib-module/PreviewCard/PreviewCard.js +0 -209
- package/lib-module/PreviewCard/index.js +0 -2
- package/lib-module/PriceLockup/PriceLockup.js +0 -335
- package/lib-module/PriceLockup/index.js +0 -2
- package/lib-module/PriceLockup/tokens.js +0 -55
- package/lib-module/Progress/ProgressBar.js +0 -83
- package/lib-module/Progress/index.js +0 -4
- package/lib-module/QuantitySelector/QuantitySelector.js +0 -261
- package/lib-module/QuantitySelector/SideButton.js +0 -70
- package/lib-module/QuantitySelector/dictionary.js +0 -26
- package/lib-module/QuantitySelector/index.js +0 -2
- package/lib-module/QuantitySelector/styles.js +0 -9
- package/lib-module/ResponsiveImage/ResponsiveImage.js +0 -95
- package/lib-module/ResponsiveImage/index.js +0 -2
- package/lib-module/Ribbon/Ribbon.js +0 -216
- package/lib-module/Ribbon/index.js +0 -2
- package/lib-module/SkeletonProvider/SkeletonImage.js +0 -39
- package/lib-module/SkeletonProvider/SkeletonProvider.js +0 -57
- package/lib-module/SkeletonProvider/SkeletonTypography.js +0 -38
- package/lib-module/SkeletonProvider/index.js +0 -2
- package/lib-module/Span/Span.js +0 -72
- package/lib-module/Span/index.js +0 -2
- package/lib-module/Spinner/Spinner.js +0 -215
- package/lib-module/Spinner/SpinnerContent.js +0 -94
- package/lib-module/Spinner/constants.js +0 -4
- package/lib-module/Spinner/index.js +0 -2
- package/lib-module/StoryCard/StoryCard.js +0 -212
- package/lib-module/StoryCard/index.js +0 -2
- package/lib-module/Table/Body.js +0 -17
- package/lib-module/Table/Cell.js +0 -176
- package/lib-module/Table/Header.js +0 -25
- package/lib-module/Table/Row.js +0 -19
- package/lib-module/Table/SubHeading.js +0 -23
- package/lib-module/Table/Table.js +0 -114
- package/lib-module/Table/index.js +0 -12
- package/lib-module/TermsAndConditions/ExpandCollapse.js +0 -153
- package/lib-module/TermsAndConditions/TermsAndConditions.js +0 -277
- package/lib-module/TermsAndConditions/dictionary.js +0 -16
- package/lib-module/TermsAndConditions/index.js +0 -1
- package/lib-module/Testimonial/Testimonial.js +0 -234
- package/lib-module/Testimonial/index.js +0 -2
- package/lib-module/Toast/Toast.js +0 -158
- package/lib-module/Toast/index.js +0 -2
- package/lib-module/Video/ControlBar/ControlBar.js +0 -288
- package/lib-module/Video/ControlBar/Controls/VideoButton/VideoButton.js +0 -70
- package/lib-module/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +0 -163
- package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +0 -203
- package/lib-module/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +0 -191
- package/lib-module/Video/MiddleControlButton/MiddleControlButton.js +0 -71
- package/lib-module/Video/Video.js +0 -959
- package/lib-module/Video/index.js +0 -2
- package/lib-module/Video/videoText.js +0 -55
- package/lib-module/VideoPicker/VideoPicker.js +0 -190
- package/lib-module/VideoPicker/VideoPickerPlayer.js +0 -48
- package/lib-module/VideoPicker/VideoPickerThumbnail.js +0 -218
- package/lib-module/VideoPicker/VideoSlider.js +0 -82
- package/lib-module/VideoPicker/index.js +0 -2
- package/lib-module/VideoPicker/videoPropType.js +0 -10
- package/lib-module/WaffleGrid/WaffleGrid.js +0 -157
- package/lib-module/WaffleGrid/index.js +0 -2
- package/lib-module/WebVideo/WebVideo.js +0 -191
- package/lib-module/WebVideo/index.js +0 -2
- package/lib-module/WebVideo/utils/index.js +0 -50
- package/lib-module/baseExports.js +0 -19
- package/lib-module/index.js +0 -40
- package/lib-module/server.js +0 -5
- package/lib-module/shared/ConditionalWrapper/ConditionalWrapper.js +0 -22
- package/lib-module/shared/ConditionalWrapper/index.js +0 -2
- package/lib-module/shared/FullBleedContent/FullBleedContent.js +0 -101
- package/lib-module/shared/FullBleedContent/getFullBleedBorderRadius.js +0 -55
- package/lib-module/shared/FullBleedContent/index.js +0 -4
- package/lib-module/shared/FullBleedContent/useFullBleedContentProps.js +0 -55
- package/lib-module/shared/VideoSplash/SplashButton/SplashButton.js +0 -84
- package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +0 -223
- package/lib-module/shared/VideoSplash/VideoSplash.js +0 -65
- package/lib-module/shared/VideoSplash/helpers.js +0 -23
- package/lib-module/utils/index.js +0 -10
- package/lib-module/utils/isElementFocusable.js +0 -8
- package/lib-module/utils/logger.js +0 -18
- package/lib-module/utils/media.js +0 -39
- package/lib-module/utils/renderStructuredContent.js +0 -66
- package/lib-module/utils/ssr.js +0 -37
- package/lib-module/utils/theming/get-theme-from-server.js +0 -16
- package/lib-module/utils/theming/with-client-theme.js +0 -24
- package/lib-module/utils/theming/with-server-theme.js +0 -26
- package/lib-module/utils/transforms.js +0 -4
- package/lib-module/utils/useOverlaidPosition.js +0 -216
- package/lib-module/utils/useTypographyTheme.js +0 -24
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { Icon, useResponsiveProp, useThemeTokens, Listbox, getTokensPropType } from '@telus-uds/components-base';
|
|
4
|
-
import NavigationItem from './NavigationItem';
|
|
5
|
-
import useOverlaidPosition from '../utils/useOverlaidPosition';
|
|
6
|
-
import resolveItemSelection from './resolveItemSelection';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* A NavigationItem that opens or closes a Listbox of other NavigationItems.
|
|
10
|
-
*
|
|
11
|
-
* This is rendered automatically by `NavigationBar` and isn't intended be used directly.
|
|
12
|
-
*/
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
15
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
const NavigationSubMenu = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
17
|
-
let {
|
|
18
|
-
children,
|
|
19
|
-
id,
|
|
20
|
-
isOpen = false,
|
|
21
|
-
tokens = {},
|
|
22
|
-
label,
|
|
23
|
-
onClick,
|
|
24
|
-
selectedId,
|
|
25
|
-
items = [],
|
|
26
|
-
openOverlayRef,
|
|
27
|
-
LinkRouter,
|
|
28
|
-
linkRouterProps,
|
|
29
|
-
itemsContainerRef
|
|
30
|
-
} = _ref;
|
|
31
|
-
const focusTrapRef = React.useRef();
|
|
32
|
-
const maxWidth = 289; // Slightly over 288 of nav item to account for subpixel rounding
|
|
33
|
-
const defaultOffsets = {
|
|
34
|
-
offsets: {
|
|
35
|
-
vertical: 4
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const {
|
|
39
|
-
align,
|
|
40
|
-
offsets,
|
|
41
|
-
minWidth
|
|
42
|
-
} = useResponsiveProp({
|
|
43
|
-
xs: {
|
|
44
|
-
...defaultOffsets,
|
|
45
|
-
align: {
|
|
46
|
-
top: 'bottom',
|
|
47
|
-
left: 'left'
|
|
48
|
-
},
|
|
49
|
-
minWidth: maxWidth
|
|
50
|
-
},
|
|
51
|
-
sm: {
|
|
52
|
-
...defaultOffsets,
|
|
53
|
-
align: {
|
|
54
|
-
top: 'bottom',
|
|
55
|
-
right: 'right'
|
|
56
|
-
},
|
|
57
|
-
minWidth: maxWidth
|
|
58
|
-
},
|
|
59
|
-
lg: {
|
|
60
|
-
...defaultOffsets,
|
|
61
|
-
align: {
|
|
62
|
-
top: 'bottom',
|
|
63
|
-
center: 'center'
|
|
64
|
-
},
|
|
65
|
-
minWidth: 192
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
const {
|
|
69
|
-
overlaidPosition,
|
|
70
|
-
sourceRef,
|
|
71
|
-
targetRef,
|
|
72
|
-
onTargetLayout,
|
|
73
|
-
isReady
|
|
74
|
-
} = useOverlaidPosition({
|
|
75
|
-
isShown: isOpen,
|
|
76
|
-
offsets,
|
|
77
|
-
align
|
|
78
|
-
});
|
|
79
|
-
const {
|
|
80
|
-
selected
|
|
81
|
-
} = resolveItemSelection({
|
|
82
|
-
id,
|
|
83
|
-
label,
|
|
84
|
-
items
|
|
85
|
-
}, selectedId);
|
|
86
|
-
const handleClick = event => {
|
|
87
|
-
if (typeof onClick === 'function') onClick(event);
|
|
88
|
-
};
|
|
89
|
-
const {
|
|
90
|
-
icoMenu
|
|
91
|
-
} = useThemeTokens('NavigationBar', {}, {}, {
|
|
92
|
-
expanded: isOpen
|
|
93
|
-
});
|
|
94
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
95
|
-
children: [/*#__PURE__*/_jsx(NavigationItem, {
|
|
96
|
-
ref: sourceRef,
|
|
97
|
-
accessibilityRole: "button",
|
|
98
|
-
id: id,
|
|
99
|
-
selected: selected,
|
|
100
|
-
onClick: handleClick,
|
|
101
|
-
icon: icoMenu,
|
|
102
|
-
tokens: tokens,
|
|
103
|
-
children: _ref2 => {
|
|
104
|
-
var _textStyles$;
|
|
105
|
-
let {
|
|
106
|
-
textStyles
|
|
107
|
-
} = _ref2;
|
|
108
|
-
return [children, /*#__PURE__*/_jsx(Icon, {
|
|
109
|
-
icon: icoMenu,
|
|
110
|
-
variant: {
|
|
111
|
-
size: 'micro'
|
|
112
|
-
},
|
|
113
|
-
tokens: {
|
|
114
|
-
color: (_textStyles$ = textStyles[0]) === null || _textStyles$ === void 0 ? void 0 : _textStyles$.color
|
|
115
|
-
}
|
|
116
|
-
}, `${id}_icon`)];
|
|
117
|
-
}
|
|
118
|
-
}), isOpen && /*#__PURE__*/_jsxs(_Fragment, {
|
|
119
|
-
children: [/*#__PURE__*/_jsx(Listbox.Overlay, {
|
|
120
|
-
overlaidPosition: overlaidPosition,
|
|
121
|
-
maxWidth: maxWidth,
|
|
122
|
-
minWidth: minWidth,
|
|
123
|
-
isReady: isReady,
|
|
124
|
-
onLayout: onTargetLayout,
|
|
125
|
-
ref: openOverlayRef,
|
|
126
|
-
children: /*#__PURE__*/_jsx(Listbox, {
|
|
127
|
-
items: items,
|
|
128
|
-
firstItemRef: targetRef,
|
|
129
|
-
parentRef: sourceRef,
|
|
130
|
-
selectedId: selectedId,
|
|
131
|
-
LinkRouter: LinkRouter,
|
|
132
|
-
linkRouterProps: linkRouterProps,
|
|
133
|
-
ref: itemsContainerRef || ref
|
|
134
|
-
})
|
|
135
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
136
|
-
// This catches and shifts focus to other interactive elements.
|
|
137
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
138
|
-
tabIndex: 0,
|
|
139
|
-
ref: focusTrapRef,
|
|
140
|
-
onFocus: () => targetRef.current.focus()
|
|
141
|
-
})]
|
|
142
|
-
})]
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
NavigationSubMenu.displayName = 'NavigationSubMenu';
|
|
146
|
-
|
|
147
|
-
// @TODO - proper prop types and comments
|
|
148
|
-
NavigationSubMenu.propTypes = {
|
|
149
|
-
tokens: getTokensPropType('NavigationBar'),
|
|
150
|
-
children: PropTypes.node,
|
|
151
|
-
id: PropTypes.string,
|
|
152
|
-
isOpen: PropTypes.bool,
|
|
153
|
-
label: PropTypes.string,
|
|
154
|
-
onClick: PropTypes.func,
|
|
155
|
-
selectedId: PropTypes.string,
|
|
156
|
-
items: PropTypes.array,
|
|
157
|
-
openOverlayRef: PropTypes.object,
|
|
158
|
-
LinkRouter: PropTypes.elementType,
|
|
159
|
-
linkRouterProps: PropTypes.object,
|
|
160
|
-
itemsContainerRef: PropTypes.object
|
|
161
|
-
};
|
|
162
|
-
export default NavigationSubMenu;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Make a list of items into a one-item list where all items are nested under the first item
|
|
3
|
-
*/
|
|
4
|
-
const collapseItems = (items, selectedId) => {
|
|
5
|
-
if (!(items !== null && items !== void 0 && items.length)) return items;
|
|
6
|
-
|
|
7
|
-
// Give the root item the label of the current active link
|
|
8
|
-
// (or the first item if for some reason there's no match on the selectedId)
|
|
9
|
-
let rootLabel = items[0].label;
|
|
10
|
-
const isSelected = _ref => {
|
|
11
|
-
let {
|
|
12
|
-
label,
|
|
13
|
-
id
|
|
14
|
-
} = _ref;
|
|
15
|
-
return selectedId === id ?? label;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// Linter doesn't like for loops, simulate loop that breaks
|
|
19
|
-
items.some(item => {
|
|
20
|
-
var _item$items;
|
|
21
|
-
if (isSelected(item)) {
|
|
22
|
-
rootLabel = item.label;
|
|
23
|
-
return true; // break
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const nestedMatch = (_item$items = item.items) === null || _item$items === void 0 ? void 0 : _item$items.find(isSelected);
|
|
27
|
-
if (nestedMatch) {
|
|
28
|
-
rootLabel = nestedMatch.label;
|
|
29
|
-
return true; // break
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return false; // continue
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return [{
|
|
36
|
-
id: 'navigation-bar-root',
|
|
37
|
-
label: rootLabel,
|
|
38
|
-
items
|
|
39
|
-
}];
|
|
40
|
-
};
|
|
41
|
-
export default collapseItems;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const resolveItemSelection = (_ref, selectedId) => {
|
|
2
|
-
let {
|
|
3
|
-
id,
|
|
4
|
-
label,
|
|
5
|
-
items
|
|
6
|
-
} = _ref;
|
|
7
|
-
const itemId = id ?? label;
|
|
8
|
-
|
|
9
|
-
// Treat item as selected if it or any nested child matches the selected id
|
|
10
|
-
const selected = Boolean(selectedId === itemId || (items === null || items === void 0 ? void 0 : items.some(item => resolveItemSelection(item, selectedId).selected)));
|
|
11
|
-
return {
|
|
12
|
-
itemId,
|
|
13
|
-
selected
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export default resolveItemSelection;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { selectSystemProps } from '@telus-uds/components-base';
|
|
4
|
-
import ResponsiveImage from '../ResponsiveImage';
|
|
5
|
-
import { hasWebpSupport, getImageUrls } from './utils';
|
|
6
|
-
import { htmlAttrs } from '../utils';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
9
|
-
const OptimizeImage = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
10
|
-
let {
|
|
11
|
-
contentfulAssetUrl,
|
|
12
|
-
alt,
|
|
13
|
-
quality = 80,
|
|
14
|
-
xs = 320,
|
|
15
|
-
sm = 576,
|
|
16
|
-
md = 768,
|
|
17
|
-
lg = 992,
|
|
18
|
-
xl = 1200,
|
|
19
|
-
sizeByHeight = false,
|
|
20
|
-
disableRetina = false,
|
|
21
|
-
...rest
|
|
22
|
-
} = _ref;
|
|
23
|
-
// `useHeight` is a deprecated TDS prop, replaced by `sizeByHeight`
|
|
24
|
-
const dimension = sizeByHeight || rest.useHeight ? 'h' : 'w';
|
|
25
|
-
// by default assuming webP support for SSR
|
|
26
|
-
const [imgUrls, setImgUrls] = React.useState(getImageUrls(contentfulAssetUrl, dimension, xs, sm, md, lg, xl, quality, disableRetina, true));
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
// Checking for webP support for CSR
|
|
29
|
-
hasWebpSupport().then(supportsWebp => {
|
|
30
|
-
const imageUrls = getImageUrls(contentfulAssetUrl, dimension, xs, sm, md, lg, xl, quality, disableRetina, supportsWebp);
|
|
31
|
-
setImgUrls(imageUrls);
|
|
32
|
-
});
|
|
33
|
-
}, [contentfulAssetUrl, dimension, disableRetina, lg, md, quality, sm, xl, xs]);
|
|
34
|
-
if (!imgUrls) return null;
|
|
35
|
-
return /*#__PURE__*/_jsx(ResponsiveImage, {
|
|
36
|
-
...imgUrls,
|
|
37
|
-
alt: alt,
|
|
38
|
-
...selectProps(rest),
|
|
39
|
-
ref: ref
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
OptimizeImage.displayName = 'OptimizeImage';
|
|
43
|
-
OptimizeImage.propTypes = {
|
|
44
|
-
...selectedSystemPropTypes,
|
|
45
|
-
/**
|
|
46
|
-
* The source to load the image. Only contentful image urls are supported. See https://www.contentful.com/developers/docs/references/images-api/ for details.
|
|
47
|
-
*/
|
|
48
|
-
contentfulAssetUrl: PropTypes.string.isRequired,
|
|
49
|
-
/**
|
|
50
|
-
* Alternative text to display if image cannot be loaded or a screen reader is used.
|
|
51
|
-
*/
|
|
52
|
-
alt: PropTypes.string.isRequired,
|
|
53
|
-
/**
|
|
54
|
-
* Customize quality as a percentage between 1 and 100.
|
|
55
|
-
*/
|
|
56
|
-
quality: PropTypes.number,
|
|
57
|
-
/**
|
|
58
|
-
* Customize width for xs screen size in px, this may affect the quality of the image.
|
|
59
|
-
*/
|
|
60
|
-
xs: PropTypes.number,
|
|
61
|
-
/**
|
|
62
|
-
* Customize width for sm screen size in px, this may affect the quality of the image.
|
|
63
|
-
*/
|
|
64
|
-
sm: PropTypes.number,
|
|
65
|
-
/**
|
|
66
|
-
* Customize width for md screen size in px, this may affect the quality of the image.
|
|
67
|
-
*/
|
|
68
|
-
md: PropTypes.number,
|
|
69
|
-
/**
|
|
70
|
-
* Customize width for lg screen size in px, this may affect the quality of the image.
|
|
71
|
-
*/
|
|
72
|
-
lg: PropTypes.number,
|
|
73
|
-
/**
|
|
74
|
-
* Customize width for xl screen size in px, this may affect the quality of the image.
|
|
75
|
-
*/
|
|
76
|
-
xl: PropTypes.number,
|
|
77
|
-
/**
|
|
78
|
-
* Switches size dimension to height, default is false
|
|
79
|
-
*/
|
|
80
|
-
sizeByHeight: PropTypes.bool,
|
|
81
|
-
/**
|
|
82
|
-
* Turns off retina display functionality
|
|
83
|
-
*/
|
|
84
|
-
disableRetina: PropTypes.bool,
|
|
85
|
-
/**
|
|
86
|
-
* Loading strategy.
|
|
87
|
-
* @default 'eager'
|
|
88
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-loading
|
|
89
|
-
*/
|
|
90
|
-
loading: PropTypes.oneOf(['eager', 'lazy'])
|
|
91
|
-
};
|
|
92
|
-
export default OptimizeImage;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import getOptimizedUrl from './getOptimizedUrl';
|
|
2
|
-
import getFallbackUrl from './getFallbackUrl';
|
|
3
|
-
export default function getImageUrls(contentfulAssetUrl, dimension, xs, sm, md, lg, xl, quality, disableRetina, supportsWebp) {
|
|
4
|
-
return {
|
|
5
|
-
xsSrc: getOptimizedUrl(contentfulAssetUrl, dimension, xs, quality, disableRetina, supportsWebp),
|
|
6
|
-
smSrc: getOptimizedUrl(contentfulAssetUrl, dimension, sm, quality, disableRetina, supportsWebp),
|
|
7
|
-
mdSrc: getOptimizedUrl(contentfulAssetUrl, dimension, md, quality, disableRetina, supportsWebp),
|
|
8
|
-
lgSrc: getOptimizedUrl(contentfulAssetUrl, dimension, lg, quality, disableRetina, supportsWebp),
|
|
9
|
-
xlSrc: getOptimizedUrl(contentfulAssetUrl, dimension, xl, quality, disableRetina, supportsWebp),
|
|
10
|
-
fallbackSrc: getFallbackUrl(contentfulAssetUrl, dimension, xl, quality)
|
|
11
|
-
};
|
|
12
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import isSvgUrl from './isSvgUrl';
|
|
2
|
-
export default function getOptimizedUrl(url, dimension, size, quality, disableRetina, supportsWebp) {
|
|
3
|
-
if (!isSvgUrl(url)) {
|
|
4
|
-
let format = '';
|
|
5
|
-
if (supportsWebp) {
|
|
6
|
-
format = 'fm=webp';
|
|
7
|
-
} else if (url.match(/\.jpe?g$/i)) {
|
|
8
|
-
format = 'fm=jpg&fl=progressive';
|
|
9
|
-
}
|
|
10
|
-
let optimizedUrl = `${url}?${dimension}=${size}&q=${quality}&${format}`;
|
|
11
|
-
if (!disableRetina) {
|
|
12
|
-
optimizedUrl += `, ${url}?${dimension}=${size * 2}&q=${quality}&${format} 2x`;
|
|
13
|
-
}
|
|
14
|
-
return optimizedUrl;
|
|
15
|
-
}
|
|
16
|
-
return url;
|
|
17
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
let promise;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Taken directly from Google developers guide on how to detect browser support for WebP.
|
|
5
|
-
*
|
|
6
|
-
* @see https://developers.google.com/speed/webp/faq#in_your_own_javascript
|
|
7
|
-
* @return {Promise<boolean>}
|
|
8
|
-
*/
|
|
9
|
-
export default function hasWebpSupport() {
|
|
10
|
-
// cache the result, so that this function runs only once
|
|
11
|
-
if (!promise) {
|
|
12
|
-
promise = new Promise(resolve => {
|
|
13
|
-
// basic support. other test forms exist for lossless, alpha, and animation types.
|
|
14
|
-
// check google guide if data strings are needed
|
|
15
|
-
const lossy = 'UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA';
|
|
16
|
-
const img = document.createElement('img');
|
|
17
|
-
img.onload = function onLoad() {
|
|
18
|
-
const result = img.width > 0 && img.height > 0;
|
|
19
|
-
resolve(result);
|
|
20
|
-
};
|
|
21
|
-
img.onerror = function onError() {
|
|
22
|
-
resolve(false);
|
|
23
|
-
};
|
|
24
|
-
img.src = `data:image/webp;base64,${lossy}`;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return promise;
|
|
28
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { applyTextStyles, getTokensPropType, selectSystemProps, StackView, Typography, useTheme, useThemeTokens, wrapStringsInText } from '@telus-uds/components-base';
|
|
5
|
-
import ItemBase from './ItemBase';
|
|
6
|
-
import { htmlAttrs } from '../utils';
|
|
7
|
-
import { OL_COUNTER_NAME } from './constants';
|
|
8
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
11
|
-
const selectItemTextStyles = (_ref, themeOptions) => {
|
|
12
|
-
let {
|
|
13
|
-
itemFontWeight,
|
|
14
|
-
itemFontSize,
|
|
15
|
-
itemLineHeight,
|
|
16
|
-
itemFontName,
|
|
17
|
-
itemColor,
|
|
18
|
-
itemTextColor
|
|
19
|
-
} = _ref;
|
|
20
|
-
return applyTextStyles({
|
|
21
|
-
fontWeight: itemFontWeight,
|
|
22
|
-
fontSize: itemFontSize,
|
|
23
|
-
fontName: itemFontName,
|
|
24
|
-
color: itemColor || itemTextColor,
|
|
25
|
-
themeOptions,
|
|
26
|
-
lineHeight: itemLineHeight
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
const StyledItemBase = /*#__PURE__*/styled(ItemBase).withConfig({
|
|
30
|
-
displayName: "Item__StyledItemBase",
|
|
31
|
-
componentId: "components-web__sc-7jzwcq-0"
|
|
32
|
-
})(_ref2 => {
|
|
33
|
-
let {
|
|
34
|
-
interItemMargin,
|
|
35
|
-
itemBulletContainerWidth,
|
|
36
|
-
itemBulletTextAlign,
|
|
37
|
-
itemFontWeight,
|
|
38
|
-
itemFontSize,
|
|
39
|
-
itemFontName,
|
|
40
|
-
itemLineHeight,
|
|
41
|
-
themeOptions,
|
|
42
|
-
listGutter,
|
|
43
|
-
itemColor,
|
|
44
|
-
itemTextColor
|
|
45
|
-
} = _ref2;
|
|
46
|
-
return {
|
|
47
|
-
counterIncrement: OL_COUNTER_NAME,
|
|
48
|
-
'::before': {
|
|
49
|
-
content: `counter(${OL_COUNTER_NAME})'.'`,
|
|
50
|
-
display: 'inline-block',
|
|
51
|
-
color: itemColor || itemTextColor,
|
|
52
|
-
width: itemBulletContainerWidth,
|
|
53
|
-
paddingRight: listGutter,
|
|
54
|
-
textAlign: itemBulletTextAlign,
|
|
55
|
-
flexShrink: 0,
|
|
56
|
-
whiteSpace: 'nowrap',
|
|
57
|
-
overflow: 'hidden',
|
|
58
|
-
...applyTextStyles({
|
|
59
|
-
fontWeight: itemFontWeight,
|
|
60
|
-
fontSize: itemFontSize,
|
|
61
|
-
fontName: itemFontName,
|
|
62
|
-
themeOptions
|
|
63
|
-
}),
|
|
64
|
-
lineHeight: `${itemLineHeight * itemFontSize}px`
|
|
65
|
-
},
|
|
66
|
-
':not(:last-child)': {
|
|
67
|
-
marginBottom: interItemMargin
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
const ItemContent = /*#__PURE__*/styled.div.withConfig({
|
|
72
|
-
displayName: "Item__ItemContent",
|
|
73
|
-
componentId: "components-web__sc-7jzwcq-1"
|
|
74
|
-
})({
|
|
75
|
-
display: 'flex',
|
|
76
|
-
flexDirection: 'column',
|
|
77
|
-
gap: 5
|
|
78
|
-
});
|
|
79
|
-
const Item = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
80
|
-
let {
|
|
81
|
-
children,
|
|
82
|
-
counterName,
|
|
83
|
-
title,
|
|
84
|
-
tokens = {},
|
|
85
|
-
variant,
|
|
86
|
-
...rest
|
|
87
|
-
} = _ref3;
|
|
88
|
-
// We are reusing some tokens from the list component here in order to provide a unified
|
|
89
|
-
// experience
|
|
90
|
-
const themeTokens = useThemeTokens('OrderedList', tokens, variant);
|
|
91
|
-
const headingTokens = title && {
|
|
92
|
-
lineHeight: themeTokens.itemLineHeight,
|
|
93
|
-
fontSize: themeTokens.itemFontSize,
|
|
94
|
-
color: themeTokens.itemColor || themeTokens.itemTextColor,
|
|
95
|
-
fontName: themeTokens.headerFontName,
|
|
96
|
-
fontWeight: themeTokens.headerFontWeight
|
|
97
|
-
};
|
|
98
|
-
const {
|
|
99
|
-
themeOptions
|
|
100
|
-
} = useTheme();
|
|
101
|
-
const itemContent = wrapStringsInText(children, {
|
|
102
|
-
style: selectItemTextStyles(themeTokens, themeOptions)
|
|
103
|
-
});
|
|
104
|
-
return /*#__PURE__*/_jsx(StyledItemBase, {
|
|
105
|
-
ref: ref,
|
|
106
|
-
themeOptions: themeOptions,
|
|
107
|
-
...themeTokens,
|
|
108
|
-
...selectProps(rest),
|
|
109
|
-
children: title ? /*#__PURE__*/_jsxs(StackView, {
|
|
110
|
-
tokens: {
|
|
111
|
-
flexShrink: 1
|
|
112
|
-
},
|
|
113
|
-
space: 0,
|
|
114
|
-
children: [/*#__PURE__*/_jsx(Typography, {
|
|
115
|
-
variant: {
|
|
116
|
-
size: 'h4'
|
|
117
|
-
},
|
|
118
|
-
tokens: headingTokens,
|
|
119
|
-
children: title
|
|
120
|
-
}), /*#__PURE__*/_jsx(ItemContent, {
|
|
121
|
-
...themeTokens,
|
|
122
|
-
children: itemContent
|
|
123
|
-
})]
|
|
124
|
-
}) : /*#__PURE__*/_jsx(ItemContent, {
|
|
125
|
-
children: itemContent
|
|
126
|
-
})
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
Item.displayName = 'OrderedListItem';
|
|
130
|
-
Item.propTypes = {
|
|
131
|
-
...selectedSystemPropTypes,
|
|
132
|
-
/**
|
|
133
|
-
* Item content
|
|
134
|
-
*/
|
|
135
|
-
children: PropTypes.node.isRequired,
|
|
136
|
-
/**
|
|
137
|
-
* Defines the title of the `OrderedList.Item`
|
|
138
|
-
*/
|
|
139
|
-
title: PropTypes.string,
|
|
140
|
-
/**
|
|
141
|
-
* Item tokens
|
|
142
|
-
*/
|
|
143
|
-
tokens: getTokensPropType('OrderedList')
|
|
144
|
-
};
|
|
145
|
-
export default Item;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
const StyledItem = /*#__PURE__*/styled.li.withConfig({
|
|
6
|
-
displayName: "ItemBase__StyledItem",
|
|
7
|
-
componentId: "components-web__sc-o0oiv5-0"
|
|
8
|
-
})({
|
|
9
|
-
display: 'flex'
|
|
10
|
-
});
|
|
11
|
-
const Item = _ref => {
|
|
12
|
-
let {
|
|
13
|
-
children,
|
|
14
|
-
...rest
|
|
15
|
-
} = _ref;
|
|
16
|
-
return /*#__PURE__*/_jsx(StyledItem, {
|
|
17
|
-
...rest,
|
|
18
|
-
children: children
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
Item.propTypes = {
|
|
22
|
-
/**
|
|
23
|
-
* Item content
|
|
24
|
-
*/
|
|
25
|
-
children: PropTypes.node.isRequired
|
|
26
|
-
};
|
|
27
|
-
export default Item;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
|
-
import { getTokensPropType, selectSystemProps, variantProp } from '@telus-uds/components-base';
|
|
5
|
-
import { htmlAttrs } from '../utils';
|
|
6
|
-
import OrderedListBase from './OrderedListBase';
|
|
7
|
-
import Item from './Item';
|
|
8
|
-
import { OL_COUNTER_NAME } from './constants';
|
|
9
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
|
|
11
|
-
const StyledOrderedListBase = /*#__PURE__*/styled(OrderedListBase).withConfig({
|
|
12
|
-
displayName: "OrderedList__StyledOrderedListBase",
|
|
13
|
-
componentId: "components-web__sc-t5az8z-0"
|
|
14
|
-
})(_ref => {
|
|
15
|
-
let {
|
|
16
|
-
start
|
|
17
|
-
} = _ref;
|
|
18
|
-
return {
|
|
19
|
-
// Using CSS counters here to have better control over the number styling
|
|
20
|
-
listStyle: 'none',
|
|
21
|
-
counterReset: `${OL_COUNTER_NAME} ${start - 1}`
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Themed semantic ordered list.
|
|
27
|
-
*/
|
|
28
|
-
const OrderedList = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
29
|
-
let {
|
|
30
|
-
children,
|
|
31
|
-
start = 1,
|
|
32
|
-
variant = {},
|
|
33
|
-
tokens = {},
|
|
34
|
-
...rest
|
|
35
|
-
} = _ref2;
|
|
36
|
-
// Check if children is an array
|
|
37
|
-
const isChildrenArray = Array.isArray(children);
|
|
38
|
-
|
|
39
|
-
// Pass any variants and tokens "OrderedList" receives down to the individual list items.
|
|
40
|
-
const childrenWithParentVariantsAndTokens = React.useMemo(() => {
|
|
41
|
-
const addVariantAndTokensToProps = child => {
|
|
42
|
-
var _child$props, _child$props2;
|
|
43
|
-
const existingChildVariants = ((_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.variant) ?? {};
|
|
44
|
-
const existingChildTokens = ((_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : _child$props2.tokens) ?? {};
|
|
45
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
46
|
-
variant: {
|
|
47
|
-
...existingChildVariants,
|
|
48
|
-
...variant
|
|
49
|
-
},
|
|
50
|
-
tokens: {
|
|
51
|
-
...existingChildTokens,
|
|
52
|
-
...tokens
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
if (variant || tokens) {
|
|
57
|
-
if (isChildrenArray) {
|
|
58
|
-
return children.map(addVariantAndTokensToProps);
|
|
59
|
-
}
|
|
60
|
-
return [addVariantAndTokensToProps(children)];
|
|
61
|
-
}
|
|
62
|
-
return children;
|
|
63
|
-
}, [children, variant, isChildrenArray, tokens]);
|
|
64
|
-
return /*#__PURE__*/_jsx(StyledOrderedListBase, {
|
|
65
|
-
...selectProps(rest),
|
|
66
|
-
ref: ref,
|
|
67
|
-
start: start,
|
|
68
|
-
children: childrenWithParentVariantsAndTokens
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
OrderedList.displayName = 'OrderedList';
|
|
72
|
-
OrderedList.propTypes = {
|
|
73
|
-
...selectedSystemPropTypes,
|
|
74
|
-
/**
|
|
75
|
-
* A list of ordered items wrapped in `OrderedList.Item`.
|
|
76
|
-
*/
|
|
77
|
-
children: PropTypes.node.isRequired,
|
|
78
|
-
/**
|
|
79
|
-
* The position to start the list with.
|
|
80
|
-
*/
|
|
81
|
-
start: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
82
|
-
variant: variantProp.propType,
|
|
83
|
-
tokens: getTokensPropType('OrderedList')
|
|
84
|
-
};
|
|
85
|
-
OrderedList.Item = Item;
|
|
86
|
-
export default OrderedList;
|