@telus-uds/components-web 2.21.2 → 2.22.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/CHANGELOG.md +13 -2
- package/lib/Badge/Badge.js +2 -14
- package/lib/Badge/index.js +0 -3
- package/lib/BlockQuote/BlockQuote.js +4 -25
- package/lib/BlockQuote/index.js +0 -3
- package/lib/Breadcrumbs/Breadcrumbs.js +9 -36
- package/lib/Breadcrumbs/Item/Item.js +15 -25
- package/lib/Breadcrumbs/index.js +0 -2
- package/lib/Callout/Callout.js +2 -24
- package/lib/Callout/index.js +0 -3
- package/lib/Card/Card.js +15 -29
- package/lib/Card/CardContent.js +5 -18
- package/lib/Card/CardFooter.js +7 -19
- package/lib/Card/index.js +0 -3
- package/lib/Countdown/Countdown.js +5 -24
- package/lib/Countdown/Segment.js +3 -15
- package/lib/Countdown/index.js +0 -3
- package/lib/Countdown/types.js +2 -7
- package/lib/Countdown/useCountdown.js +0 -7
- package/lib/DatePicker/CalendarContainer.js +0 -5
- package/lib/DatePicker/DatePicker.js +9 -61
- package/lib/DatePicker/dictionary.js +0 -8
- package/lib/DatePicker/index.js +0 -3
- package/lib/DatePicker/reactDatesCss.js +0 -2
- package/lib/Disclaimer/Disclaimer.js +5 -14
- package/lib/Disclaimer/index.js +0 -2
- package/lib/ExpandCollapseMini/ExpandCollapseMini.js +6 -17
- package/lib/ExpandCollapseMini/ExpandCollapseMiniControl.js +12 -25
- package/lib/ExpandCollapseMini/index.js +0 -3
- package/lib/Footnote/Footnote.js +17 -63
- package/lib/Footnote/FootnoteLink.js +3 -24
- package/lib/Footnote/index.js +0 -4
- package/lib/IconButton/IconButton.js +4 -14
- package/lib/IconButton/index.js +0 -3
- package/lib/Image/Image.js +5 -24
- package/lib/Image/index.js +0 -3
- package/lib/List/List.js +0 -2
- package/lib/List/ListItem.js +0 -8
- package/lib/List/index.js +0 -4
- package/lib/NavigationBar/NavigationBar.js +10 -35
- package/lib/NavigationBar/NavigationItem.js +5 -17
- package/lib/NavigationBar/NavigationSubMenu.js +3 -19
- package/lib/NavigationBar/collapseItems.js +6 -9
- package/lib/NavigationBar/index.js +0 -3
- package/lib/NavigationBar/resolveItemSelection.js +2 -3
- package/lib/OptimizeImage/OptimizeImage.js +6 -27
- package/lib/OptimizeImage/index.js +0 -3
- package/lib/OptimizeImage/utils/getFallbackUrl.js +0 -4
- package/lib/OptimizeImage/utils/getOptimizedUrl.js +0 -8
- package/lib/OptimizeImage/utils/hasWebpSupport.js +1 -5
- package/lib/OptimizeImage/utils/index.js +0 -4
- package/lib/OptimizeImage/utils/isSvgUrl.js +0 -1
- package/lib/OrderedList/Item.js +4 -21
- package/lib/OrderedList/ItemBase.js +2 -9
- package/lib/OrderedList/OrderedList.js +11 -22
- package/lib/OrderedList/OrderedListBase.js +3 -13
- package/lib/OrderedList/index.js +0 -4
- package/lib/Paragraph/Paragraph.js +3 -18
- package/lib/Paragraph/index.js +0 -3
- package/lib/PreviewCard/AuthorDate.js +1 -10
- package/lib/PreviewCard/PreviewCard.js +15 -35
- package/lib/PreviewCard/index.js +0 -3
- package/lib/PriceLockup/PriceLockup.js +78 -75
- package/lib/PriceLockup/index.js +0 -3
- package/lib/PriceLockup/tokens.js +0 -2
- package/lib/Progress/ProgressBar.js +5 -16
- package/lib/Progress/index.js +0 -4
- package/lib/QuantitySelector/QuantitySelector.js +8 -42
- package/lib/QuantitySelector/SideButton.js +4 -11
- package/lib/QuantitySelector/index.js +0 -3
- package/lib/QuantitySelector/styles.js +0 -6
- package/lib/ResponsiveImage/ResponsiveImage.js +5 -20
- package/lib/ResponsiveImage/index.js +0 -3
- package/lib/Ribbon/Ribbon.js +4 -20
- package/lib/Ribbon/index.js +0 -3
- package/lib/SkeletonProvider/SkeletonImage.js +0 -10
- package/lib/SkeletonProvider/SkeletonProvider.js +4 -22
- package/lib/SkeletonProvider/SkeletonTypography.js +0 -10
- package/lib/SkeletonProvider/index.js +0 -3
- package/lib/Span/Span.js +3 -17
- package/lib/Span/index.js +0 -3
- package/lib/Spinner/Spinner.js +11 -39
- package/lib/Spinner/SpinnerContent.js +2 -18
- package/lib/Spinner/index.js +0 -3
- package/lib/StoryCard/StoryCard.js +11 -31
- package/lib/StoryCard/index.js +0 -3
- package/lib/Table/Body.js +0 -6
- package/lib/Table/Cell.js +4 -24
- package/lib/Table/Header.js +0 -9
- package/lib/Table/Row.js +0 -8
- package/lib/Table/SubHeading.js +0 -9
- package/lib/Table/Table.js +5 -23
- package/lib/Table/index.js +0 -8
- package/lib/TermsAndConditions/ExpandCollapse.js +4 -14
- package/lib/TermsAndConditions/TermsAndConditions.js +7 -29
- package/lib/TermsAndConditions/index.js +0 -2
- package/lib/Testimonial/Testimonial.js +2 -26
- package/lib/Testimonial/index.js +0 -3
- package/lib/Toast/Toast.js +4 -25
- package/lib/Toast/index.js +0 -3
- package/lib/Video/ControlBar/ControlBar.js +2 -25
- package/lib/Video/ControlBar/Controls/VideoButton/VideoButton.js +4 -17
- package/lib/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +4 -20
- package/lib/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +12 -26
- package/lib/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +8 -23
- package/lib/Video/MiddleControlButton/MiddleControlButton.js +2 -12
- package/lib/Video/Video.js +122 -194
- package/lib/Video/index.js +0 -3
- package/lib/VideoPicker/VideoPicker.js +6 -32
- package/lib/VideoPicker/VideoPickerPlayer.js +2 -10
- package/lib/VideoPicker/VideoPickerThumbnail.js +7 -28
- package/lib/VideoPicker/VideoSlider.js +7 -17
- package/lib/VideoPicker/index.js +0 -3
- package/lib/VideoPicker/videoPropType.js +2 -8
- package/lib/WaffleGrid/WaffleGrid.js +11 -28
- package/lib/WaffleGrid/index.js +0 -3
- package/lib/WebPortal/WebPortal.js +1 -5
- package/lib/WebPortal/index.js +0 -3
- package/lib/WebVideo/WebVideo.js +4 -30
- package/lib/WebVideo/index.js +0 -3
- package/lib/baseExports.js +6 -1
- package/lib/index.js +0 -49
- package/lib/shared/FullBleedContent/FullBleedContent.js +5 -17
- package/lib/shared/FullBleedContent/getFullBleedBorderRadius.js +0 -11
- package/lib/shared/FullBleedContent/index.js +0 -5
- package/lib/shared/FullBleedContent/useFullBleedContentProps.js +1 -12
- package/lib/shared/VideoSplash/SplashButton/SplashButton.js +2 -12
- package/lib/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +7 -23
- package/lib/shared/VideoSplash/VideoSplash.js +4 -17
- package/lib/shared/VideoSplash/helpers.js +0 -6
- package/lib/utils/index.js +0 -9
- package/lib/utils/logger.js +0 -6
- package/lib/utils/media.js +2 -11
- package/lib/utils/renderStructuredContent.js +14 -31
- package/lib/utils/ssr.js +0 -6
- package/lib/utils/transforms.js +0 -2
- package/lib/utils/useOverlaidPosition.js +6 -28
- package/lib/utils/useTypographyTheme.js +4 -5
- package/lib-module/Badge/Badge.js +2 -5
- package/lib-module/BlockQuote/BlockQuote.js +4 -15
- package/lib-module/Breadcrumbs/Breadcrumbs.js +9 -25
- package/lib-module/Breadcrumbs/Item/Item.js +15 -12
- package/lib-module/Callout/Callout.js +2 -16
- package/lib-module/Card/Card.js +14 -17
- package/lib-module/Card/CardContent.js +5 -8
- package/lib-module/Card/CardFooter.js +7 -9
- package/lib-module/Countdown/Countdown.js +6 -11
- package/lib-module/Countdown/Segment.js +6 -8
- package/lib-module/Countdown/types.js +2 -1
- package/lib-module/Countdown/useCountdown.js +0 -6
- package/lib-module/DatePicker/CalendarContainer.js +3 -1
- package/lib-module/DatePicker/DatePicker.js +9 -39
- package/lib-module/DatePicker/dictionary.js +0 -8
- package/lib-module/Disclaimer/Disclaimer.js +5 -4
- package/lib-module/ExpandCollapseMini/ExpandCollapseMini.js +6 -8
- package/lib-module/ExpandCollapseMini/ExpandCollapseMiniControl.js +13 -19
- package/lib-module/Footnote/Footnote.js +17 -41
- package/lib-module/Footnote/FootnoteLink.js +3 -12
- package/lib-module/IconButton/IconButton.js +4 -6
- package/lib-module/Image/Image.js +5 -14
- package/lib-module/NavigationBar/NavigationBar.js +10 -20
- package/lib-module/NavigationBar/NavigationItem.js +5 -5
- package/lib-module/NavigationBar/NavigationSubMenu.js +3 -8
- package/lib-module/NavigationBar/collapseItems.js +6 -8
- package/lib-module/NavigationBar/resolveItemSelection.js +2 -2
- package/lib-module/OptimizeImage/OptimizeImage.js +6 -16
- package/lib-module/OptimizeImage/utils/getFallbackUrl.js +0 -1
- package/lib-module/OptimizeImage/utils/getOptimizedUrl.js +0 -5
- package/lib-module/OptimizeImage/utils/hasWebpSupport.js +1 -5
- package/lib-module/OrderedList/Item.js +4 -7
- package/lib-module/OrderedList/ItemBase.js +2 -3
- package/lib-module/OrderedList/OrderedList.js +11 -9
- package/lib-module/OrderedList/OrderedListBase.js +3 -3
- package/lib-module/Paragraph/Paragraph.js +3 -8
- package/lib-module/PreviewCard/AuthorDate.js +1 -4
- package/lib-module/PreviewCard/PreviewCard.js +16 -19
- package/lib-module/PriceLockup/PriceLockup.js +78 -57
- package/lib-module/Progress/ProgressBar.js +7 -8
- package/lib-module/QuantitySelector/QuantitySelector.js +8 -30
- package/lib-module/QuantitySelector/SideButton.js +4 -6
- package/lib-module/ResponsiveImage/ResponsiveImage.js +5 -12
- package/lib-module/Ribbon/Ribbon.js +4 -9
- package/lib-module/SkeletonProvider/SkeletonImage.js +0 -5
- package/lib-module/SkeletonProvider/SkeletonProvider.js +4 -12
- package/lib-module/SkeletonProvider/SkeletonTypography.js +0 -5
- package/lib-module/Span/Span.js +3 -7
- package/lib-module/Spinner/Spinner.js +11 -24
- package/lib-module/Spinner/SpinnerContent.js +2 -8
- package/lib-module/StoryCard/StoryCard.js +12 -17
- package/lib-module/Table/Body.js +0 -2
- package/lib-module/Table/Cell.js +4 -14
- package/lib-module/Table/Header.js +0 -2
- package/lib-module/Table/Row.js +0 -2
- package/lib-module/Table/SubHeading.js +0 -2
- package/lib-module/Table/Table.js +5 -6
- package/lib-module/TermsAndConditions/ExpandCollapse.js +4 -2
- package/lib-module/TermsAndConditions/TermsAndConditions.js +7 -9
- package/lib-module/Testimonial/Testimonial.js +2 -11
- package/lib-module/Toast/Toast.js +4 -15
- package/lib-module/Video/ControlBar/ControlBar.js +2 -9
- package/lib-module/Video/ControlBar/Controls/VideoButton/VideoButton.js +4 -8
- package/lib-module/Video/ControlBar/Controls/VideoMenu/VideoMenu.js +4 -8
- package/lib-module/Video/ControlBar/Controls/VideoProgressBar/VideoProgressBar.js +12 -13
- package/lib-module/Video/ControlBar/Controls/VolumeSlider/VolumeSlider.js +8 -10
- package/lib-module/Video/MiddleControlButton/MiddleControlButton.js +2 -3
- package/lib-module/Video/Video.js +122 -173
- package/lib-module/VideoPicker/VideoPicker.js +6 -15
- package/lib-module/VideoPicker/VideoPickerPlayer.js +2 -3
- package/lib-module/VideoPicker/VideoPickerThumbnail.js +7 -13
- package/lib-module/VideoPicker/VideoSlider.js +6 -9
- package/lib-module/VideoPicker/videoPropType.js +2 -1
- package/lib-module/WaffleGrid/WaffleGrid.js +11 -15
- package/lib-module/WebPortal/WebPortal.js +1 -1
- package/lib-module/WebVideo/WebVideo.js +4 -15
- package/lib-module/baseExports.js +3 -2
- package/lib-module/index.js +0 -1
- package/lib-module/shared/FullBleedContent/FullBleedContent.js +5 -10
- package/lib-module/shared/FullBleedContent/getFullBleedBorderRadius.js +0 -10
- package/lib-module/shared/FullBleedContent/useFullBleedContentProps.js +1 -11
- package/lib-module/shared/VideoSplash/SplashButton/SplashButton.js +2 -3
- package/lib-module/shared/VideoSplash/SplashButtonWithDetails/SplashButtonWithDetails.js +7 -12
- package/lib-module/shared/VideoSplash/VideoSplash.js +4 -4
- package/lib-module/utils/logger.js +2 -2
- package/lib-module/utils/media.js +2 -9
- package/lib-module/utils/renderStructuredContent.js +14 -25
- package/lib-module/utils/ssr.js +0 -4
- package/lib-module/utils/useOverlaidPosition.js +8 -27
- package/lib-module/utils/useTypographyTheme.js +4 -4
- package/package.json +3 -3
- package/src/PriceLockup/PriceLockup.jsx +36 -11
- package/src/baseExports.js +1 -0
- package/src/index.js +0 -1
- package/lib/Modal/Modal.js +0 -146
- package/lib/Modal/ModalContent.js +0 -203
- package/lib/Modal/index.js +0 -13
- package/lib-module/Modal/Modal.js +0 -132
- package/lib-module/Modal/ModalContent.js +0 -181
- package/lib-module/Modal/index.js +0 -2
- package/src/Modal/Modal.jsx +0 -121
- package/src/Modal/ModalContent.jsx +0 -167
- package/src/Modal/index.js +0 -3
package/lib/List/index.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _List = _interopRequireDefault(require("./List"));
|
|
9
|
-
|
|
10
8
|
var _ListItem = _interopRequireDefault(require("./ListItem"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
_List.default.Item = _ListItem.default;
|
|
15
11
|
var _default = _List.default;
|
|
16
12
|
exports.default = _default;
|
|
@@ -4,35 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _componentsBase = require("@telus-uds/components-base");
|
|
13
|
-
|
|
14
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
-
|
|
16
11
|
var _utils = require("../utils");
|
|
17
|
-
|
|
18
12
|
var _NavigationItem = _interopRequireDefault(require("./NavigationItem"));
|
|
19
|
-
|
|
20
13
|
var _NavigationSubMenu = _interopRequireDefault(require("./NavigationSubMenu"));
|
|
21
|
-
|
|
22
14
|
var _collapseItems = _interopRequireDefault(require("./collapseItems"));
|
|
23
|
-
|
|
24
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
|
-
|
|
26
16
|
var _withLinkRouter$propT, _withLinkRouter$propT2, _withLinkRouter$propT3, _withLinkRouter$propT4;
|
|
27
|
-
|
|
28
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
|
|
30
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
-
|
|
32
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
|
|
34
20
|
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
|
|
35
|
-
|
|
36
21
|
const Heading = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
37
22
|
displayName: "NavigationBar__Heading",
|
|
38
23
|
componentId: "components-web__sc-1vis1gt-0"
|
|
@@ -46,12 +31,11 @@ const Heading = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
|
46
31
|
letterSpacing: 0
|
|
47
32
|
}
|
|
48
33
|
});
|
|
34
|
+
|
|
49
35
|
/**
|
|
50
36
|
* NavigationBar can be used to allow customers to consistently navigate across
|
|
51
37
|
* key pages within a specific product line
|
|
52
38
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
39
|
const NavigationBar = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
56
40
|
let {
|
|
57
41
|
accessibilityRole = 'navigation',
|
|
@@ -74,10 +58,8 @@ const NavigationBar = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
74
58
|
});
|
|
75
59
|
const openOverlayRef = (0, _react.useRef)(null);
|
|
76
60
|
const [openSubMenuId, setOpenSubMenuId] = (0, _react.useState)(null);
|
|
77
|
-
|
|
78
61
|
const handleSubMenuClose = event => {
|
|
79
62
|
var _openOverlayRef$curre, _openOverlayRef$curre2;
|
|
80
|
-
|
|
81
63
|
if (event.type === 'keydown') {
|
|
82
64
|
if (event.key === 'Escape' || event.key === 27) {
|
|
83
65
|
setOpenSubMenuId(null);
|
|
@@ -87,17 +69,16 @@ const NavigationBar = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
87
69
|
} else if (event.type === 'touchstart' && openOverlayRef !== null && openOverlayRef !== void 0 && openOverlayRef.current && event.touches[0].target && !(openOverlayRef !== null && openOverlayRef !== void 0 && (_openOverlayRef$curre2 = openOverlayRef.current) !== null && _openOverlayRef$curre2 !== void 0 && _openOverlayRef$curre2.contains(event.touches[0].target))) {
|
|
88
70
|
setOpenSubMenuId(null);
|
|
89
71
|
}
|
|
90
|
-
};
|
|
91
|
-
// TODO: create a custom hook for that and use here and in the Footnote
|
|
92
|
-
|
|
72
|
+
};
|
|
93
73
|
|
|
74
|
+
// Add listeners for mouse clicks outside and for ESCAPE key presses
|
|
75
|
+
// TODO: create a custom hook for that and use here and in the Footnote
|
|
94
76
|
(0, _react.useEffect)(() => {
|
|
95
77
|
if (openSubMenuId !== null) {
|
|
96
78
|
window.addEventListener('click', handleSubMenuClose);
|
|
97
79
|
window.addEventListener('keydown', handleSubMenuClose);
|
|
98
80
|
window.addEventListener('touchstart', handleSubMenuClose);
|
|
99
81
|
}
|
|
100
|
-
|
|
101
82
|
return () => {
|
|
102
83
|
if (openSubMenuId !== null) {
|
|
103
84
|
window.removeEventListener('click', handleSubMenuClose);
|
|
@@ -137,27 +118,26 @@ const NavigationBar = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
137
118
|
...itemRest
|
|
138
119
|
} = _ref2;
|
|
139
120
|
const itemId = id ?? label;
|
|
140
|
-
|
|
141
121
|
const handleClick = event => {
|
|
142
122
|
if (nestedItems) {
|
|
143
123
|
setOpenSubMenuId(openSubMenuId !== itemId ? itemId : null);
|
|
144
124
|
}
|
|
145
|
-
|
|
146
125
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
147
126
|
onChange === null || onChange === void 0 ? void 0 : onChange(itemId, event);
|
|
148
127
|
};
|
|
149
|
-
|
|
150
128
|
const ItemComponent = nestedItems ? _NavigationSubMenu.default : _NavigationItem.default;
|
|
151
129
|
const isOpen = itemId === openSubMenuId;
|
|
152
130
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ItemComponent, {
|
|
153
131
|
ref: itemRef,
|
|
154
132
|
href: href,
|
|
155
|
-
onClick: handleClick
|
|
133
|
+
onClick: handleClick
|
|
134
|
+
// TODO: refactor to pass selected ID via context
|
|
156
135
|
,
|
|
157
136
|
selectedId: selectedId,
|
|
158
137
|
index: index,
|
|
159
138
|
LinkRouter: ItemLinkRouter,
|
|
160
|
-
linkRouterProps: {
|
|
139
|
+
linkRouterProps: {
|
|
140
|
+
...linkRouterProps,
|
|
161
141
|
...itemLinkRouterProps
|
|
162
142
|
},
|
|
163
143
|
items: nestedItems,
|
|
@@ -175,10 +155,10 @@ const NavigationBar = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
175
155
|
});
|
|
176
156
|
});
|
|
177
157
|
NavigationBar.displayName = 'NavigationBar';
|
|
178
|
-
NavigationBar.propTypes = {
|
|
158
|
+
NavigationBar.propTypes = {
|
|
159
|
+
...selectedSystemPropTypes,
|
|
179
160
|
tokens: (0, _componentsBase.getTokensPropType)('NavigationBar'),
|
|
180
161
|
..._componentsBase.withLinkRouter.propTypes,
|
|
181
|
-
|
|
182
162
|
/**
|
|
183
163
|
* NavigationBar pages
|
|
184
164
|
*
|
|
@@ -206,27 +186,22 @@ NavigationBar.propTypes = { ...selectedSystemPropTypes,
|
|
|
206
186
|
linkRouterProps: (_withLinkRouter$propT4 = _componentsBase.withLinkRouter.propTypes) === null || _withLinkRouter$propT4 === void 0 ? void 0 : _withLinkRouter$propT4.linkRouterProps
|
|
207
187
|
}))
|
|
208
188
|
})).isRequired,
|
|
209
|
-
|
|
210
189
|
/**
|
|
211
190
|
* Common navigation bar heading.
|
|
212
191
|
*/
|
|
213
192
|
heading: _propTypes.default.string,
|
|
214
|
-
|
|
215
193
|
/**
|
|
216
194
|
* Sets the `headingLevel` of the `heading`
|
|
217
195
|
*/
|
|
218
196
|
headingLevel: _propTypes.default.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
|
|
219
|
-
|
|
220
197
|
/**
|
|
221
198
|
* Matches the `id` property of the item in `items` corresponding to the current page
|
|
222
199
|
*/
|
|
223
200
|
selectedId: _propTypes.default.string.isRequired,
|
|
224
|
-
|
|
225
201
|
/**
|
|
226
202
|
* Optional function to be called on pressing a link
|
|
227
203
|
*/
|
|
228
204
|
onChange: _propTypes.default.func,
|
|
229
|
-
|
|
230
205
|
/**
|
|
231
206
|
* Accesibility role for stackview
|
|
232
207
|
*/
|
|
@@ -4,28 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _componentsBase = require("@telus-uds/components-base");
|
|
13
|
-
|
|
14
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
-
|
|
16
11
|
var _utils = require("../utils");
|
|
17
|
-
|
|
18
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
-
|
|
24
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
-
|
|
26
16
|
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils.htmlAttrs]);
|
|
27
17
|
const defaultMaxWidth = 192;
|
|
28
|
-
|
|
29
18
|
const ItemContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
30
19
|
displayName: "NavigationItem__ItemContainer",
|
|
31
20
|
componentId: "components-web__sc-ql9x7c-0"
|
|
@@ -42,13 +31,12 @@ const ItemContainer = /*#__PURE__*/_styledComponents.default.div.withConfig({
|
|
|
42
31
|
flexShrink: 1
|
|
43
32
|
};
|
|
44
33
|
});
|
|
34
|
+
|
|
45
35
|
/**
|
|
46
36
|
* NavigationItem within a NavigationBar component.
|
|
47
37
|
*
|
|
48
38
|
* This is rendered automatically by `NavigationBar` and isn't intended be used directly.
|
|
49
39
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
40
|
const NavigationItem = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
53
41
|
let {
|
|
54
42
|
accessibilityRole = 'link',
|
|
@@ -74,11 +62,10 @@ const NavigationItem = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
74
62
|
});
|
|
75
63
|
const viewport = (0, _componentsBase.useViewport)();
|
|
76
64
|
const getTokens = (0, _componentsBase.useThemeTokensCallback)('NavigationBar', tokens, variant);
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
const getStateTokens = state => getTokens({
|
|
66
|
+
...state,
|
|
79
67
|
viewport
|
|
80
68
|
});
|
|
81
|
-
|
|
82
69
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ItemContainer, {
|
|
83
70
|
targetWidth: targetWidth,
|
|
84
71
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Button, {
|
|
@@ -99,7 +86,8 @@ const NavigationItem = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|
|
99
86
|
});
|
|
100
87
|
});
|
|
101
88
|
NavigationItem.displayName = 'NavigationItem';
|
|
102
|
-
NavigationItem.propTypes = {
|
|
89
|
+
NavigationItem.propTypes = {
|
|
90
|
+
...selectedSystemPropTypes,
|
|
103
91
|
onClick: _propTypes.default.func,
|
|
104
92
|
selected: _propTypes.default.bool,
|
|
105
93
|
children: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]).isRequired
|
|
@@ -4,33 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _componentsBase = require("@telus-uds/components-base");
|
|
13
|
-
|
|
14
10
|
var _NavigationItem = _interopRequireDefault(require("./NavigationItem"));
|
|
15
|
-
|
|
16
11
|
var _useOverlaidPosition = _interopRequireDefault(require("../utils/useOverlaidPosition"));
|
|
17
|
-
|
|
18
12
|
var _resolveItemSelection = _interopRequireDefault(require("./resolveItemSelection"));
|
|
19
|
-
|
|
20
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
-
|
|
22
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
-
|
|
26
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
-
|
|
28
17
|
/**
|
|
29
18
|
* A NavigationItem that opens or closes a Listbox of other NavigationItems.
|
|
30
19
|
*
|
|
31
20
|
* This is rendered automatically by `NavigationBar` and isn't intended be used directly.
|
|
32
|
-
*/
|
|
33
|
-
const NavigationSubMenu = _ref => {
|
|
21
|
+
*/const NavigationSubMenu = _ref => {
|
|
34
22
|
let {
|
|
35
23
|
children,
|
|
36
24
|
id,
|
|
@@ -45,7 +33,6 @@ const NavigationSubMenu = _ref => {
|
|
|
45
33
|
} = _ref;
|
|
46
34
|
const focusTrapRef = (0, _react.useRef)();
|
|
47
35
|
const maxWidth = 289; // Slightly over 288 of nav item to account for subpixel rounding
|
|
48
|
-
|
|
49
36
|
const {
|
|
50
37
|
align,
|
|
51
38
|
offsets,
|
|
@@ -94,11 +81,9 @@ const NavigationSubMenu = _ref => {
|
|
|
94
81
|
label,
|
|
95
82
|
items
|
|
96
83
|
}, selectedId);
|
|
97
|
-
|
|
98
84
|
const handleClick = event => {
|
|
99
85
|
if (typeof onClick === 'function') onClick(event);
|
|
100
86
|
};
|
|
101
|
-
|
|
102
87
|
const {
|
|
103
88
|
icoMenu
|
|
104
89
|
} = (0, _componentsBase.useThemeTokens)('NavigationBar', {}, {}, {
|
|
@@ -114,7 +99,6 @@ const NavigationSubMenu = _ref => {
|
|
|
114
99
|
icon: icoMenu,
|
|
115
100
|
children: _ref2 => {
|
|
116
101
|
var _textStyles$;
|
|
117
|
-
|
|
118
102
|
let {
|
|
119
103
|
textStyles
|
|
120
104
|
} = _ref2;
|
|
@@ -154,9 +138,9 @@ const NavigationSubMenu = _ref => {
|
|
|
154
138
|
})]
|
|
155
139
|
});
|
|
156
140
|
};
|
|
141
|
+
NavigationSubMenu.displayName = 'NavigationSubMenu';
|
|
157
142
|
|
|
158
|
-
|
|
159
|
-
|
|
143
|
+
// @TODO - proper prop types and comments
|
|
160
144
|
NavigationSubMenu.propTypes = {
|
|
161
145
|
children: _propTypes.default.node,
|
|
162
146
|
id: _propTypes.default.string,
|
|
@@ -4,35 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Make a list of items into a one-item list where all items are nested under the first item
|
|
10
9
|
*/
|
|
11
10
|
const collapseItems = (items, selectedId) => {
|
|
12
|
-
if (!(items !== null && items !== void 0 && items.length)) return items;
|
|
13
|
-
// (or the first item if for some reason there's no match on the selectedId)
|
|
11
|
+
if (!(items !== null && items !== void 0 && items.length)) return items;
|
|
14
12
|
|
|
13
|
+
// Give the root item the label of the current active link
|
|
14
|
+
// (or the first item if for some reason there's no match on the selectedId)
|
|
15
15
|
let rootLabel = items[0].label;
|
|
16
|
-
|
|
17
16
|
const isSelected = _ref => {
|
|
18
17
|
let {
|
|
19
18
|
label,
|
|
20
19
|
id
|
|
21
20
|
} = _ref;
|
|
22
21
|
return selectedId === id ?? label;
|
|
23
|
-
};
|
|
24
|
-
|
|
22
|
+
};
|
|
25
23
|
|
|
24
|
+
// Linter doesn't like for loops, simulate loop that breaks
|
|
26
25
|
items.some(item => {
|
|
27
26
|
var _item$items;
|
|
28
|
-
|
|
29
27
|
if (isSelected(item)) {
|
|
30
28
|
rootLabel = item.label;
|
|
31
29
|
return true; // break
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
const nestedMatch = (_item$items = item.items) === null || _item$items === void 0 ? void 0 : _item$items.find(isSelected);
|
|
35
|
-
|
|
36
33
|
if (nestedMatch) {
|
|
37
34
|
rootLabel = nestedMatch.label;
|
|
38
35
|
return true; // break
|
|
@@ -40,12 +37,12 @@ const collapseItems = (items, selectedId) => {
|
|
|
40
37
|
|
|
41
38
|
return false; // continue
|
|
42
39
|
});
|
|
40
|
+
|
|
43
41
|
return [{
|
|
44
42
|
id: 'navigation-bar-root',
|
|
45
43
|
label: rootLabel,
|
|
46
44
|
items
|
|
47
45
|
}];
|
|
48
46
|
};
|
|
49
|
-
|
|
50
47
|
var _default = collapseItems;
|
|
51
48
|
exports.default = _default;
|
|
@@ -4,10 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _NavigationBar = _interopRequireDefault(require("./NavigationBar"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
var _default = _NavigationBar.default;
|
|
13
10
|
exports.default = _default;
|
|
@@ -4,21 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
const resolveItemSelection = (_ref, selectedId) => {
|
|
9
8
|
let {
|
|
10
9
|
id,
|
|
11
10
|
label,
|
|
12
11
|
items
|
|
13
12
|
} = _ref;
|
|
14
|
-
const itemId = id ?? label;
|
|
13
|
+
const itemId = id ?? label;
|
|
15
14
|
|
|
15
|
+
// Treat item as selected if it or any nested child matches the selected id
|
|
16
16
|
const selected = Boolean(selectedId === itemId || (items === null || items === void 0 ? void 0 : items.some(item => resolveItemSelection(item, selectedId).selected)));
|
|
17
17
|
return {
|
|
18
18
|
itemId,
|
|
19
19
|
selected
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
|
|
23
22
|
var _default = resolveItemSelection;
|
|
24
23
|
exports.default = _default;
|
|
@@ -4,29 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _componentsBase = require("@telus-uds/components-base");
|
|
13
|
-
|
|
14
10
|
var _ResponsiveImage = _interopRequireDefault(require("../ResponsiveImage"));
|
|
15
|
-
|
|
16
11
|
var _utils = require("./utils");
|
|
17
|
-
|
|
18
12
|
var _utils2 = require("../utils");
|
|
19
|
-
|
|
20
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
-
|
|
22
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
-
|
|
26
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
-
|
|
28
17
|
const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_utils2.htmlAttrs]);
|
|
29
|
-
|
|
30
18
|
const OptimizeImage = _ref => {
|
|
31
19
|
let {
|
|
32
20
|
contentfulAssetUrl,
|
|
@@ -41,8 +29,9 @@ const OptimizeImage = _ref => {
|
|
|
41
29
|
disableRetina = false,
|
|
42
30
|
...rest
|
|
43
31
|
} = _ref;
|
|
44
|
-
const [imgUrls, setImgUrls] = (0, _react.useState)();
|
|
32
|
+
const [imgUrls, setImgUrls] = (0, _react.useState)();
|
|
45
33
|
|
|
34
|
+
// `useHeight` is a deprecated TDS prop, replaced by `sizeByHeight`
|
|
46
35
|
const dimension = sizeByHeight || rest.useHeight ? 'h' : 'w';
|
|
47
36
|
(0, _react.useEffect)(() => {
|
|
48
37
|
// Currently not all browsers support webP
|
|
@@ -58,64 +47,54 @@ const OptimizeImage = _ref => {
|
|
|
58
47
|
});
|
|
59
48
|
}, [contentfulAssetUrl, dimension, disableRetina, lg, md, quality, sm, xl, xs]);
|
|
60
49
|
if (!imgUrls) return null;
|
|
61
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ResponsiveImage.default, {
|
|
50
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ResponsiveImage.default, {
|
|
51
|
+
...imgUrls,
|
|
62
52
|
alt: alt,
|
|
63
53
|
...selectProps(rest)
|
|
64
54
|
});
|
|
65
55
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
OptimizeImage.propTypes = {
|
|
57
|
+
...selectedSystemPropTypes,
|
|
69
58
|
/**
|
|
70
59
|
* The source to load the image. Only contentful image urls are supported. See https://www.contentful.com/developers/docs/references/images-api/ for details.
|
|
71
60
|
*/
|
|
72
61
|
contentfulAssetUrl: _propTypes.default.string.isRequired,
|
|
73
|
-
|
|
74
62
|
/**
|
|
75
63
|
* Alternative text to display if image cannot be loaded or a screen reader is used.
|
|
76
64
|
*/
|
|
77
65
|
alt: _propTypes.default.string.isRequired,
|
|
78
|
-
|
|
79
66
|
/**
|
|
80
67
|
* Customize quality as a percentage between 1 and 100.
|
|
81
68
|
*/
|
|
82
69
|
quality: _propTypes.default.number,
|
|
83
|
-
|
|
84
70
|
/**
|
|
85
71
|
* Customize width for xs screen size in px, this may affect the quality of the image.
|
|
86
72
|
*/
|
|
87
73
|
xs: _propTypes.default.number,
|
|
88
|
-
|
|
89
74
|
/**
|
|
90
75
|
* Customize width for sm screen size in px, this may affect the quality of the image.
|
|
91
76
|
*/
|
|
92
77
|
sm: _propTypes.default.number,
|
|
93
|
-
|
|
94
78
|
/**
|
|
95
79
|
* Customize width for md screen size in px, this may affect the quality of the image.
|
|
96
80
|
*/
|
|
97
81
|
md: _propTypes.default.number,
|
|
98
|
-
|
|
99
82
|
/**
|
|
100
83
|
* Customize width for lg screen size in px, this may affect the quality of the image.
|
|
101
84
|
*/
|
|
102
85
|
lg: _propTypes.default.number,
|
|
103
|
-
|
|
104
86
|
/**
|
|
105
87
|
* Customize width for xl screen size in px, this may affect the quality of the image.
|
|
106
88
|
*/
|
|
107
89
|
xl: _propTypes.default.number,
|
|
108
|
-
|
|
109
90
|
/**
|
|
110
91
|
* Switches size dimension to height, default is false
|
|
111
92
|
*/
|
|
112
93
|
sizeByHeight: _propTypes.default.bool,
|
|
113
|
-
|
|
114
94
|
/**
|
|
115
95
|
* Turns off retina display functionality
|
|
116
96
|
*/
|
|
117
97
|
disableRetina: _propTypes.default.bool,
|
|
118
|
-
|
|
119
98
|
/**
|
|
120
99
|
* Loading strategy.
|
|
121
100
|
* @default 'eager'
|
|
@@ -4,10 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _OptimizeImage = _interopRequireDefault(require("./OptimizeImage"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
var _default = _OptimizeImage.default;
|
|
13
10
|
exports.default = _default;
|
|
@@ -4,15 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = getFallbackUrl;
|
|
7
|
-
|
|
8
7
|
var _isSvgUrl = _interopRequireDefault(require("./isSvgUrl"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
function getFallbackUrl(url, width, quality) {
|
|
13
10
|
if (!(0, _isSvgUrl.default)(url)) {
|
|
14
11
|
return `${url}?w=${width}&q=${quality}`;
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
return url;
|
|
18
14
|
}
|
|
@@ -4,29 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = getOptimizedUrl;
|
|
7
|
-
|
|
8
7
|
var _isSvgUrl = _interopRequireDefault(require("./isSvgUrl"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
function getOptimizedUrl(url, dimension, size, quality, disableRetina, supportsWebp) {
|
|
13
10
|
if (!(0, _isSvgUrl.default)(url)) {
|
|
14
11
|
let format = '';
|
|
15
|
-
|
|
16
12
|
if (supportsWebp) {
|
|
17
13
|
format = 'fm=webp';
|
|
18
14
|
} else if (url.match(/\.jpe?g$/i)) {
|
|
19
15
|
format = 'fm=jpg&fl=progressive';
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
let optimizedUrl = `${url}?${dimension}=${size}&q=${quality}&${format}`;
|
|
23
|
-
|
|
24
18
|
if (!disableRetina) {
|
|
25
19
|
optimizedUrl += `, ${url}?${dimension}=${size * 2}&q=${quality}&${format} 2x`;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
return optimizedUrl;
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
return url;
|
|
32
24
|
}
|
|
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = hasWebpSupport;
|
|
7
7
|
let promise;
|
|
8
|
+
|
|
8
9
|
/**
|
|
9
10
|
* Taken directly from Google developers guide on how to detect browser support for WebP.
|
|
10
11
|
*
|
|
11
12
|
* @see https://developers.google.com/speed/webp/faq#in_your_own_javascript
|
|
12
13
|
* @return {Promise<boolean>}
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
15
|
function hasWebpSupport() {
|
|
16
16
|
// cache the result, so that this function runs only once
|
|
17
17
|
if (!promise) {
|
|
@@ -20,19 +20,15 @@ function hasWebpSupport() {
|
|
|
20
20
|
// check google guide if data strings are needed
|
|
21
21
|
const lossy = 'UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA';
|
|
22
22
|
const img = document.createElement('img');
|
|
23
|
-
|
|
24
23
|
img.onload = function onLoad() {
|
|
25
24
|
const result = img.width > 0 && img.height > 0;
|
|
26
25
|
resolve(result);
|
|
27
26
|
};
|
|
28
|
-
|
|
29
27
|
img.onerror = function onError() {
|
|
30
28
|
resolve(false);
|
|
31
29
|
};
|
|
32
|
-
|
|
33
30
|
img.src = `data:image/webp;base64,${lossy}`;
|
|
34
31
|
});
|
|
35
32
|
}
|
|
36
|
-
|
|
37
33
|
return promise;
|
|
38
34
|
}
|
|
@@ -21,11 +21,7 @@ Object.defineProperty(exports, "hasWebpSupport", {
|
|
|
21
21
|
return _hasWebpSupport.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
|
|
25
24
|
var _getOptimizedUrl = _interopRequireDefault(require("./getOptimizedUrl"));
|
|
26
|
-
|
|
27
25
|
var _getFallbackUrl = _interopRequireDefault(require("./getFallbackUrl"));
|
|
28
|
-
|
|
29
26
|
var _hasWebpSupport = _interopRequireDefault(require("./hasWebpSupport"));
|
|
30
|
-
|
|
31
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|