@telus-uds/components-base 3.29.1 → 3.30.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 +15 -1
- package/lib/cjs/Carousel/Carousel.js +6 -1
- package/lib/cjs/Carousel/CarouselThumbnail.js +123 -31
- package/lib/cjs/Carousel/CarouselThumbnailNavigation.js +8 -1
- package/lib/cjs/Footnote/FootnoteLink.js +18 -17
- package/lib/cjs/Progress/Progress.js +30 -5
- package/lib/cjs/Scroll/Scroll.js +466 -0
- package/lib/cjs/Scroll/ScrollContext.js +55 -0
- package/lib/cjs/Scroll/ScrollItem.js +103 -0
- package/lib/cjs/Scroll/ScrollProgress.js +99 -0
- package/lib/cjs/Scroll/dictionary.js +18 -0
- package/lib/cjs/Scroll/index.js +29 -0
- package/lib/cjs/index.js +15 -0
- package/lib/cjs/utils/animation/index.js +7 -0
- package/lib/cjs/utils/animation/useAnimatedValue.js +46 -0
- package/lib/cjs/utils/children.js +2 -1
- package/lib/esm/Carousel/Carousel.js +6 -1
- package/lib/esm/Carousel/CarouselThumbnail.js +124 -32
- package/lib/esm/Carousel/CarouselThumbnailNavigation.js +8 -1
- package/lib/esm/Footnote/FootnoteLink.js +18 -17
- package/lib/esm/Progress/Progress.js +30 -5
- package/lib/esm/Scroll/Scroll.js +459 -0
- package/lib/esm/Scroll/ScrollContext.js +47 -0
- package/lib/esm/Scroll/ScrollItem.js +96 -0
- package/lib/esm/Scroll/ScrollProgress.js +92 -0
- package/lib/esm/Scroll/dictionary.js +12 -0
- package/lib/esm/Scroll/index.js +4 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/utils/animation/index.js +1 -1
- package/lib/esm/utils/animation/useAnimatedValue.js +39 -0
- package/lib/esm/utils/children.js +2 -1
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/src/Carousel/Carousel.jsx +6 -1
- package/src/Carousel/CarouselThumbnail.jsx +153 -64
- package/src/Carousel/CarouselThumbnailNavigation.jsx +8 -2
- package/src/Footnote/FootnoteLink.jsx +17 -12
- package/src/Progress/Progress.jsx +22 -3
- package/src/Scroll/Scroll.jsx +488 -0
- package/src/Scroll/ScrollContext.jsx +41 -0
- package/src/Scroll/ScrollItem.jsx +89 -0
- package/src/Scroll/ScrollProgress.jsx +75 -0
- package/src/Scroll/dictionary.js +12 -0
- package/src/Scroll/index.js +5 -0
- package/src/index.js +1 -0
- package/src/utils/animation/index.js +1 -1
- package/src/utils/animation/useAnimatedValue.js +37 -0
- package/src/utils/children.jsx +4 -1
- package/types/Scroll.d.ts +66 -0
- package/types/index.d.ts +9 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
var _Progress = _interopRequireDefault(require("../Progress"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
const MAX_PERCENTAGE = 100;
|
|
15
|
+
const BORDER_RADIUS_DIVISOR = 2;
|
|
16
|
+
const staticProgressTokens = {
|
|
17
|
+
borderWidth: 0,
|
|
18
|
+
borderColor: 'transparent'
|
|
19
|
+
};
|
|
20
|
+
const staticProgressBarTokens = {
|
|
21
|
+
gradient: null,
|
|
22
|
+
outlineWidth: 0
|
|
23
|
+
};
|
|
24
|
+
const selectProgressTokens = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
progressTrackHeight,
|
|
27
|
+
progressBarHeight,
|
|
28
|
+
progressTrackColor
|
|
29
|
+
} = _ref;
|
|
30
|
+
return {
|
|
31
|
+
height: progressTrackHeight,
|
|
32
|
+
barHeight: progressBarHeight,
|
|
33
|
+
backgroundColor: progressTrackColor,
|
|
34
|
+
borderRadius: progressTrackHeight / BORDER_RADIUS_DIVISOR
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const selectBarTokens = _ref2 => {
|
|
38
|
+
let {
|
|
39
|
+
progressBarColor,
|
|
40
|
+
progressBarHeight
|
|
41
|
+
} = _ref2;
|
|
42
|
+
return {
|
|
43
|
+
backgroundColor: progressBarColor,
|
|
44
|
+
borderRadius: progressBarHeight / BORDER_RADIUS_DIVISOR
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
const ScrollProgress = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
48
|
+
let {
|
|
49
|
+
pressableState,
|
|
50
|
+
getTokens,
|
|
51
|
+
thumbWrapperStyle,
|
|
52
|
+
getCopy
|
|
53
|
+
} = _ref3;
|
|
54
|
+
const state = (0, _utils.resolvePressableState)(pressableState);
|
|
55
|
+
const themeTokens = getTokens(state);
|
|
56
|
+
const animatedBarHeight = (0, _utils.useAnimatedValue)(themeTokens.progressBarHeight);
|
|
57
|
+
const animatedTokens = {
|
|
58
|
+
...themeTokens,
|
|
59
|
+
progressBarHeight: animatedBarHeight
|
|
60
|
+
};
|
|
61
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Progress.default, {
|
|
62
|
+
tokens: {
|
|
63
|
+
...staticProgressTokens,
|
|
64
|
+
...selectProgressTokens(animatedTokens)
|
|
65
|
+
},
|
|
66
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
67
|
+
ref: ref,
|
|
68
|
+
style: thumbWrapperStyle,
|
|
69
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Progress.default.Bar, {
|
|
70
|
+
percentage: MAX_PERCENTAGE,
|
|
71
|
+
tokens: {
|
|
72
|
+
...staticProgressBarTokens,
|
|
73
|
+
...selectBarTokens(animatedTokens)
|
|
74
|
+
},
|
|
75
|
+
accessibilityLabel: getCopy('progressBarLabel')
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
ScrollProgress.displayName = 'ScrollProgress';
|
|
81
|
+
ScrollProgress.propTypes = {
|
|
82
|
+
/**
|
|
83
|
+
* State object from Pressable's render callback containing hovered, pressed, and focused states
|
|
84
|
+
*/
|
|
85
|
+
pressableState: _propTypes.default.object.isRequired,
|
|
86
|
+
/**
|
|
87
|
+
* Theme token resolver callback from useThemeTokensCallback that accepts appearance state
|
|
88
|
+
*/
|
|
89
|
+
getTokens: _propTypes.default.func.isRequired,
|
|
90
|
+
/**
|
|
91
|
+
* Style array for the thumb wrapper containing static and dynamic position styles
|
|
92
|
+
*/
|
|
93
|
+
thumbWrapperStyle: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.array]).isRequired,
|
|
94
|
+
/**
|
|
95
|
+
* Copy resolver function from useCopy for retrieving localized strings
|
|
96
|
+
*/
|
|
97
|
+
getCopy: _propTypes.default.func.isRequired
|
|
98
|
+
};
|
|
99
|
+
var _default = exports.default = ScrollProgress;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = exports.default = {
|
|
8
|
+
en: {
|
|
9
|
+
accessibilityLabel: 'Scrollable content',
|
|
10
|
+
instructionText: 'Use Tab, arrow keys, or space bar to navigate',
|
|
11
|
+
progressBarLabel: 'Scroll position'
|
|
12
|
+
},
|
|
13
|
+
fr: {
|
|
14
|
+
accessibilityLabel: 'Contenu défilable',
|
|
15
|
+
instructionText: "Utilisez Tab, les touches fléchées ou la barre d'espace pour naviguer",
|
|
16
|
+
progressBarLabel: 'Position de défilement'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ScrollItem", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ScrollItem.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ScrollProvider", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _ScrollContext.ScrollProvider;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.default = void 0;
|
|
19
|
+
Object.defineProperty(exports, "useScroll", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _ScrollContext.useScroll;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var _Scroll = _interopRequireDefault(require("./Scroll"));
|
|
26
|
+
var _ScrollItem = _interopRequireDefault(require("./ScrollItem"));
|
|
27
|
+
var _ScrollContext = require("./ScrollContext");
|
|
28
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
29
|
+
var _default = exports.default = _Scroll.default;
|
package/lib/cjs/index.js
CHANGED
|
@@ -57,6 +57,8 @@ var _exportNames = {
|
|
|
57
57
|
RadioCard: true,
|
|
58
58
|
RadioCardGroup: true,
|
|
59
59
|
Responsive: true,
|
|
60
|
+
Scroll: true,
|
|
61
|
+
ScrollItem: true,
|
|
60
62
|
Search: true,
|
|
61
63
|
Select: true,
|
|
62
64
|
Shortcuts: true,
|
|
@@ -422,6 +424,18 @@ Object.defineProperty(exports, "Responsive", {
|
|
|
422
424
|
return _Responsive.default;
|
|
423
425
|
}
|
|
424
426
|
});
|
|
427
|
+
Object.defineProperty(exports, "Scroll", {
|
|
428
|
+
enumerable: true,
|
|
429
|
+
get: function () {
|
|
430
|
+
return _Scroll.default;
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
Object.defineProperty(exports, "ScrollItem", {
|
|
434
|
+
enumerable: true,
|
|
435
|
+
get: function () {
|
|
436
|
+
return _Scroll.ScrollItem;
|
|
437
|
+
}
|
|
438
|
+
});
|
|
425
439
|
Object.defineProperty(exports, "Search", {
|
|
426
440
|
enumerable: true,
|
|
427
441
|
get: function () {
|
|
@@ -756,6 +770,7 @@ var _QuickLinksFeature = _interopRequireDefault(require("./QuickLinksFeature"));
|
|
|
756
770
|
var _Radio = _interopRequireWildcard(require("./Radio"));
|
|
757
771
|
var _RadioCard = _interopRequireWildcard(require("./RadioCard"));
|
|
758
772
|
var _Responsive = _interopRequireDefault(require("./Responsive"));
|
|
773
|
+
var _Scroll = _interopRequireWildcard(require("./Scroll"));
|
|
759
774
|
var _Search = _interopRequireDefault(require("./Search"));
|
|
760
775
|
var _Select = _interopRequireDefault(require("./Select"));
|
|
761
776
|
var _Shortcuts = _interopRequireWildcard(require("./Shortcuts"));
|
|
@@ -3,11 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "useAnimatedValue", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useAnimatedValue.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "useVerticalExpandAnimation", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
9
15
|
return _useVerticalExpandAnimation.default;
|
|
10
16
|
}
|
|
11
17
|
});
|
|
18
|
+
var _useAnimatedValue = _interopRequireDefault(require("./useAnimatedValue"));
|
|
12
19
|
var _useVerticalExpandAnimation = _interopRequireDefault(require("./useVerticalExpandAnimation"));
|
|
13
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _Animated = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Animated"));
|
|
9
|
+
var _Easing = _interopRequireDefault(require("react-native-web/dist/cjs/exports/Easing"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const ANIMATION_DURATION = 200;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Smoothly animates a numeric value to a new target using a quadratic ease-in-out
|
|
15
|
+
* curve. Returns the current interpolated value as a plain number so
|
|
16
|
+
* consumers can use it in non-Animated style props.
|
|
17
|
+
*
|
|
18
|
+
* @param {number} targetValue - The value to animate towards.
|
|
19
|
+
* @param {number} [duration=ANIMATION_DURATION] - Animation duration in ms.
|
|
20
|
+
*/
|
|
21
|
+
const useAnimatedValue = function (targetValue) {
|
|
22
|
+
let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ANIMATION_DURATION;
|
|
23
|
+
const [currentValue, setCurrentValue] = _react.default.useState(targetValue);
|
|
24
|
+
const animatedValue = _react.default.useRef(new _Animated.default.Value(targetValue)).current;
|
|
25
|
+
_react.default.useEffect(() => {
|
|
26
|
+
const id = animatedValue.addListener(_ref => {
|
|
27
|
+
let {
|
|
28
|
+
value
|
|
29
|
+
} = _ref;
|
|
30
|
+
return setCurrentValue(value);
|
|
31
|
+
});
|
|
32
|
+
return () => animatedValue.removeListener(id);
|
|
33
|
+
}, [animatedValue]);
|
|
34
|
+
_react.default.useEffect(() => {
|
|
35
|
+
const animation = _Animated.default.timing(animatedValue, {
|
|
36
|
+
toValue: targetValue,
|
|
37
|
+
duration,
|
|
38
|
+
easing: _Easing.default.inOut(_Easing.default.quad),
|
|
39
|
+
useNativeDriver: false
|
|
40
|
+
});
|
|
41
|
+
animation.start();
|
|
42
|
+
return () => animation.stop();
|
|
43
|
+
}, [targetValue, animatedValue, duration]);
|
|
44
|
+
return currentValue;
|
|
45
|
+
};
|
|
46
|
+
var _default = exports.default = useAnimatedValue;
|
|
@@ -54,7 +54,8 @@ const unpackFragment = child => {
|
|
|
54
54
|
exports.unpackFragment = unpackFragment;
|
|
55
55
|
const isStringOrNumber = child => typeof child === 'string' || typeof child === 'number';
|
|
56
56
|
// Wrap an A11yText with neighouring text strings so it doesn't split them into multiple <Text>s
|
|
57
|
-
|
|
57
|
+
// Check displayName first as it is explicitly set and reliable regardless of export style (named vs default)
|
|
58
|
+
const isWrapable = child => isStringOrNumber(child) || child.type === _A11yText.default || child.type?.__UDS_COMPONENT_NAME__ === 'FootnoteLink';
|
|
58
59
|
const combineKeys = childrenArray => childrenArray.reduce((newKey, child) => `${newKey}${child.key || ''}`, '');
|
|
59
60
|
|
|
60
61
|
// Group wrappable children for one `<Text>` parent, merging adjacent text nodes
|
|
@@ -1170,9 +1170,14 @@ Carousel.propTypes = {
|
|
|
1170
1170
|
* An array of objects containing information on the thumbnails to be rendered as navigation panel
|
|
1171
1171
|
*/
|
|
1172
1172
|
thumbnails: PropTypes.arrayOf(PropTypes.shape({
|
|
1173
|
+
/** Accessibility label for the thumbnail image, used by assistive technologies. */
|
|
1173
1174
|
accessibilityLabel: PropTypes.string,
|
|
1175
|
+
/** Alternative text for the thumbnail image, displayed when the image cannot be rendered. */
|
|
1174
1176
|
alt: PropTypes.string,
|
|
1175
|
-
|
|
1177
|
+
/** When true, renders a play icon overlay on the thumbnail to indicate that the slide contains a video. */
|
|
1178
|
+
isVideo: PropTypes.bool,
|
|
1179
|
+
/** URL or path of the thumbnail image. When used with `isVideo`, this should be the video's poster/preview image. */
|
|
1180
|
+
src: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
1176
1181
|
})),
|
|
1177
1182
|
/**
|
|
1178
1183
|
* Minimal part of slide width must be swiped for changing index.
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import StyleSheet from "react-native-web/dist/exports/StyleSheet";
|
|
3
4
|
import Pressable from "react-native-web/dist/exports/Pressable";
|
|
4
5
|
import Image from "react-native-web/dist/exports/Image";
|
|
6
|
+
import View from "react-native-web/dist/exports/View";
|
|
5
7
|
import { useCarousel } from './CarouselContext';
|
|
6
8
|
import { useThemeTokensCallback } from '../ThemeProvider';
|
|
7
9
|
import { useViewport } from '../ViewportProvider';
|
|
8
|
-
import
|
|
10
|
+
import Icon from '../Icon';
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
12
|
const selectPressableTokens = _ref => {
|
|
10
13
|
let {
|
|
11
14
|
borderColor,
|
|
@@ -23,17 +26,64 @@ const selectPressableTokens = _ref => {
|
|
|
23
26
|
};
|
|
24
27
|
};
|
|
25
28
|
|
|
29
|
+
// Play icon overlay appearance is consistent across all brands and is not theme-configurable.
|
|
30
|
+
// The circle occupies 55% of the thumbnail size, and the icon occupies 55% of the circle diameter.
|
|
31
|
+
const PLAY_ICON_RATIO = 0.55;
|
|
32
|
+
const PLAY_ICON_BORDER_RADIUS_DIVISOR = 2;
|
|
33
|
+
const selectImageStyles = size => ({
|
|
34
|
+
width: size,
|
|
35
|
+
height: size
|
|
36
|
+
});
|
|
37
|
+
const selectSelectedStyles = _ref2 => {
|
|
38
|
+
let {
|
|
39
|
+
selectedBorderColor,
|
|
40
|
+
selectedBorderWidth,
|
|
41
|
+
padding,
|
|
42
|
+
margin
|
|
43
|
+
} = _ref2;
|
|
44
|
+
return {
|
|
45
|
+
borderColor: selectedBorderColor,
|
|
46
|
+
borderWidth: selectedBorderWidth,
|
|
47
|
+
padding: padding - selectedBorderWidth,
|
|
48
|
+
marginBottom: margin + selectedBorderWidth
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const selectNonSelectedStyles = _ref3 => {
|
|
52
|
+
let {
|
|
53
|
+
borderWidth,
|
|
54
|
+
padding,
|
|
55
|
+
margin,
|
|
56
|
+
selectedBorderWidth
|
|
57
|
+
} = _ref3;
|
|
58
|
+
return {
|
|
59
|
+
padding: padding - borderWidth,
|
|
60
|
+
marginBottom: margin + selectedBorderWidth
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const selectPlayIconCircleStyles = thumbnailSize => {
|
|
64
|
+
const diameter = thumbnailSize * PLAY_ICON_RATIO;
|
|
65
|
+
return {
|
|
66
|
+
width: diameter,
|
|
67
|
+
height: diameter,
|
|
68
|
+
borderRadius: diameter / PLAY_ICON_BORDER_RADIUS_DIVISOR
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
const selectPlayIconTokens = thumbnailSize => ({
|
|
72
|
+
size: thumbnailSize * PLAY_ICON_RATIO * PLAY_ICON_RATIO
|
|
73
|
+
});
|
|
74
|
+
|
|
26
75
|
/**
|
|
27
76
|
* `Carousel.Thumbnail` is used to wrap the content of an individual slide and is suppsoed to be the
|
|
28
77
|
* only top-level component passed to the `Carousel`
|
|
29
78
|
*/
|
|
30
|
-
const CarouselThumbnail = /*#__PURE__*/React.forwardRef((
|
|
79
|
+
const CarouselThumbnail = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
31
80
|
let {
|
|
32
81
|
accessibilityLabel,
|
|
33
82
|
alt,
|
|
34
83
|
index,
|
|
84
|
+
isVideo,
|
|
35
85
|
src
|
|
36
|
-
} =
|
|
86
|
+
} = _ref4;
|
|
37
87
|
const {
|
|
38
88
|
activeIndex,
|
|
39
89
|
itemLabel,
|
|
@@ -55,59 +105,101 @@ const CarouselThumbnail = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
55
105
|
selectedBorderColor,
|
|
56
106
|
selectedBorderWidth,
|
|
57
107
|
size,
|
|
58
|
-
margin
|
|
108
|
+
margin,
|
|
109
|
+
playIcon
|
|
59
110
|
} = getThumbnailTokens({
|
|
60
111
|
viewport
|
|
61
112
|
});
|
|
62
|
-
const styles = {
|
|
63
|
-
image: {
|
|
64
|
-
height: size,
|
|
65
|
-
width: size
|
|
66
|
-
},
|
|
67
|
-
selected: {
|
|
68
|
-
borderColor: selectedBorderColor,
|
|
69
|
-
borderWidth: selectedBorderWidth,
|
|
70
|
-
padding: padding - selectedBorderWidth,
|
|
71
|
-
marginBottom: margin + selectedBorderWidth
|
|
72
|
-
},
|
|
73
|
-
nonSelected: {
|
|
74
|
-
padding: padding - borderWidth,
|
|
75
|
-
marginBottom: margin + selectedBorderWidth
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
113
|
return /*#__PURE__*/_jsx(Pressable, {
|
|
79
114
|
onKeyDown: handleKeyDown,
|
|
80
115
|
onPress: handlePress,
|
|
81
|
-
style:
|
|
116
|
+
style: _ref5 => {
|
|
82
117
|
let {
|
|
83
118
|
hovered,
|
|
84
119
|
pressed,
|
|
85
120
|
focused
|
|
86
|
-
} =
|
|
121
|
+
} = _ref5;
|
|
87
122
|
const pressableStyles = selectPressableTokens(getThumbnailTokens({
|
|
88
123
|
hover: hovered,
|
|
89
124
|
pressed,
|
|
90
125
|
focus: focused
|
|
91
126
|
}));
|
|
92
|
-
return [pressableStyles, index === activeIndex ? [
|
|
93
|
-
|
|
94
|
-
|
|
127
|
+
return [pressableStyles, index === activeIndex ? [selectSelectedStyles({
|
|
128
|
+
selectedBorderColor,
|
|
129
|
+
selectedBorderWidth,
|
|
130
|
+
padding,
|
|
131
|
+
margin
|
|
132
|
+
}), staticStyles.selectedPressableOutline] : selectNonSelectedStyles({
|
|
133
|
+
borderWidth,
|
|
134
|
+
padding,
|
|
135
|
+
margin,
|
|
136
|
+
selectedBorderWidth
|
|
137
|
+
})];
|
|
95
138
|
},
|
|
96
139
|
ref: ref,
|
|
97
|
-
children: /*#__PURE__*/
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
140
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
141
|
+
style: [staticStyles.imageContainer, selectImageStyles(size)],
|
|
142
|
+
children: [/*#__PURE__*/_jsx(Image, {
|
|
143
|
+
accessibilityIgnoresInvertColors: true,
|
|
144
|
+
accessibilityLabel: accessibilityLabel ?? alt,
|
|
145
|
+
source: src,
|
|
146
|
+
style: selectImageStyles(size),
|
|
147
|
+
title: thumbnailTitle
|
|
148
|
+
}), isVideo && playIcon && /*#__PURE__*/_jsx(View, {
|
|
149
|
+
style: staticStyles.playIconOverlayContainer,
|
|
150
|
+
testID: `play-icon-overlay-${index}`,
|
|
151
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
152
|
+
style: [selectPlayIconCircleStyles(size), staticStyles.playIconCircleBackground],
|
|
153
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
154
|
+
icon: playIcon,
|
|
155
|
+
tokens: {
|
|
156
|
+
...selectPlayIconTokens(size),
|
|
157
|
+
color: staticStyles.playIconSymbol.color
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
})]
|
|
103
162
|
})
|
|
104
163
|
}, src);
|
|
105
164
|
});
|
|
106
165
|
CarouselThumbnail.displayName = 'CarouselThumbnail';
|
|
107
166
|
CarouselThumbnail.propTypes = {
|
|
167
|
+
/** Accessibility label for screen readers, overrides the alt text */
|
|
108
168
|
accessibilityLabel: PropTypes.string,
|
|
169
|
+
/** Alt text for the thumbnail image */
|
|
109
170
|
alt: PropTypes.string,
|
|
171
|
+
/** Zero-based index of this thumbnail within the carousel */
|
|
110
172
|
index: PropTypes.number,
|
|
111
|
-
|
|
173
|
+
/**
|
|
174
|
+
* When true, renders a play icon overlay on the thumbnail to indicate that the slide contains a video.
|
|
175
|
+
*/
|
|
176
|
+
isVideo: PropTypes.bool,
|
|
177
|
+
/** Image source URI (web) or local asset require() (native) */
|
|
178
|
+
src: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
112
179
|
};
|
|
180
|
+
const staticStyles = StyleSheet.create({
|
|
181
|
+
imageContainer: {
|
|
182
|
+
position: 'relative'
|
|
183
|
+
},
|
|
184
|
+
playIconOverlayContainer: {
|
|
185
|
+
position: 'absolute',
|
|
186
|
+
top: 0,
|
|
187
|
+
left: 0,
|
|
188
|
+
right: 0,
|
|
189
|
+
bottom: 0,
|
|
190
|
+
justifyContent: 'center',
|
|
191
|
+
alignItems: 'center'
|
|
192
|
+
},
|
|
193
|
+
selectedPressableOutline: {
|
|
194
|
+
outlineStyle: 'none'
|
|
195
|
+
},
|
|
196
|
+
playIconCircleBackground: {
|
|
197
|
+
backgroundColor: 'rgba(0, 0, 0, 0.6)',
|
|
198
|
+
justifyContent: 'center',
|
|
199
|
+
alignItems: 'center'
|
|
200
|
+
},
|
|
201
|
+
playIconSymbol: {
|
|
202
|
+
color: 'rgb(255, 255, 255)'
|
|
203
|
+
}
|
|
204
|
+
});
|
|
113
205
|
export default CarouselThumbnail;
|
|
@@ -45,12 +45,14 @@ const CarouselThumbnailNavigation = /*#__PURE__*/React.forwardRef((_ref, ref) =>
|
|
|
45
45
|
let {
|
|
46
46
|
accessibilityLabel,
|
|
47
47
|
alt,
|
|
48
|
+
isVideo,
|
|
48
49
|
src
|
|
49
50
|
} = _ref2;
|
|
50
51
|
return /*#__PURE__*/_jsx(CarouselThumbnail, {
|
|
51
52
|
accessibilityLabel: accessibilityLabel,
|
|
52
53
|
alt: alt,
|
|
53
54
|
index: index,
|
|
55
|
+
isVideo: isVideo,
|
|
54
56
|
src: src
|
|
55
57
|
}, src);
|
|
56
58
|
})
|
|
@@ -63,9 +65,14 @@ CarouselThumbnailNavigation.propTypes = {
|
|
|
63
65
|
* An array of objects containing information on the thumbnail images.
|
|
64
66
|
*/
|
|
65
67
|
thumbnails: PropTypes.arrayOf(PropTypes.shape({
|
|
68
|
+
/** Accessibility label for the thumbnail image, used by assistive technologies. */
|
|
66
69
|
accessibilityLabel: PropTypes.string,
|
|
70
|
+
/** Alternative text for the thumbnail image, displayed when the image cannot be rendered. */
|
|
67
71
|
alt: PropTypes.string,
|
|
68
|
-
|
|
72
|
+
/** When true, renders a play icon overlay on the thumbnail to indicate that the slide contains a video. */
|
|
73
|
+
isVideo: PropTypes.bool,
|
|
74
|
+
/** URL or path of the thumbnail image. When used with `isVideo`, this should be the video's poster/preview image. */
|
|
75
|
+
src: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
69
76
|
})).isRequired
|
|
70
77
|
};
|
|
71
78
|
export default CarouselThumbnailNavigation;
|
|
@@ -9,28 +9,28 @@ import { htmlAttrs, selectSystemProps, useCopy, viewProps, wrapStringsInText, va
|
|
|
9
9
|
import { applyTextStyles, useThemeTokens } from '../ThemeProvider';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs, viewProps]);
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const HALF_FONT_SIZE = 2;
|
|
13
|
+
const QUARTER_FONT_SIZE = 4;
|
|
14
|
+
const DEFAULT_LINE_HEIGHT = 1;
|
|
15
|
+
const LINE_HEIGHT_MULTIPLIER = 2;
|
|
14
16
|
const selectTextStyle = _ref => {
|
|
15
17
|
let {
|
|
16
18
|
fontSize,
|
|
17
19
|
lineHeight
|
|
18
20
|
} = _ref;
|
|
19
|
-
return {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
};
|
|
21
|
+
return Platform.select({
|
|
22
|
+
native: {
|
|
23
|
+
fontSize: fontSize / HALF_FONT_SIZE,
|
|
24
|
+
lineHeight: fontSize,
|
|
25
|
+
position: 'relative',
|
|
26
|
+
top: -(fontSize * lineHeight) / HALF_FONT_SIZE
|
|
27
|
+
},
|
|
28
|
+
web: {
|
|
29
|
+
fontSize,
|
|
30
|
+
lineHeight: lineHeight !== DEFAULT_LINE_HEIGHT ? lineHeight : fontSize * LINE_HEIGHT_MULTIPLIER,
|
|
31
|
+
top: -fontSize / QUARTER_FONT_SIZE
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
34
|
};
|
|
35
35
|
const FootnoteLink = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
36
36
|
let {
|
|
@@ -74,6 +74,7 @@ const FootnoteLink = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
FootnoteLink.displayName = 'FootnoteLink';
|
|
77
|
+
FootnoteLink.__UDS_COMPONENT_NAME__ = 'FootnoteLink';
|
|
77
78
|
const copyShape = PropTypes.shape({
|
|
78
79
|
a11yLabel: PropTypes.string.isRequired
|
|
79
80
|
});
|
|
@@ -7,6 +7,8 @@ import { a11yProps, getTokensPropType, selectSystemProps, variantProp, viewProps
|
|
|
7
7
|
import ProgressContext from './ProgressContext';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, viewProps]);
|
|
10
|
+
const BORDER_SIDES = 2;
|
|
11
|
+
const CENTER_DIVISOR = 2;
|
|
10
12
|
const selectProgressStyles = _ref => {
|
|
11
13
|
let {
|
|
12
14
|
backgroundColor,
|
|
@@ -25,6 +27,21 @@ const selectProgressStyles = _ref => {
|
|
|
25
27
|
...applyShadowToken(shadow)
|
|
26
28
|
};
|
|
27
29
|
};
|
|
30
|
+
const selectBarWrapperStyles = _ref2 => {
|
|
31
|
+
let {
|
|
32
|
+
barHeight,
|
|
33
|
+
borderRadius,
|
|
34
|
+
borderWidth,
|
|
35
|
+
height
|
|
36
|
+
} = _ref2;
|
|
37
|
+
return {
|
|
38
|
+
height: barHeight,
|
|
39
|
+
width: '100%',
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
top: (height - borderWidth * BORDER_SIDES - barHeight) / CENTER_DIVISOR,
|
|
42
|
+
borderRadius
|
|
43
|
+
};
|
|
44
|
+
};
|
|
28
45
|
|
|
29
46
|
/**
|
|
30
47
|
* The `Progress` is a container for displaying one or several `ProgressBar`s.
|
|
@@ -38,10 +55,11 @@ const selectProgressStyles = _ref => {
|
|
|
38
55
|
*
|
|
39
56
|
* - Use the following tokens to customize the appearance:
|
|
40
57
|
* - `backgroundColor` for the background color of the progress container,
|
|
58
|
+
* - `barHeight` to control the height of the progress bars displayed within the container,
|
|
41
59
|
* - `borderColor` to control the color of the border,
|
|
42
60
|
* - `borderRadius` for the rounded corners,
|
|
43
61
|
* - `borderWidth` to change the border width.
|
|
44
|
-
* - `height` to control the height of the progress
|
|
62
|
+
* - `height` to control the height of the progress bar container.
|
|
45
63
|
* - `shadow` to apply a box shadow to the progress bar container.
|
|
46
64
|
*
|
|
47
65
|
* ## Variants
|
|
@@ -62,16 +80,23 @@ const selectProgressStyles = _ref => {
|
|
|
62
80
|
* role.
|
|
63
81
|
*
|
|
64
82
|
*/
|
|
65
|
-
const Progress = /*#__PURE__*/React.forwardRef((
|
|
83
|
+
const Progress = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
66
84
|
let {
|
|
67
85
|
children,
|
|
68
86
|
tokens,
|
|
69
87
|
variant,
|
|
70
88
|
...rest
|
|
71
|
-
} =
|
|
89
|
+
} = _ref3;
|
|
72
90
|
const themeTokens = useThemeTokens('Progress', tokens, variant);
|
|
73
|
-
// Default to false (vertical layout) to preserve existing behavior and avoid breaking changes
|
|
74
91
|
const layers = variant?.layers ?? false;
|
|
92
|
+
const {
|
|
93
|
+
barHeight,
|
|
94
|
+
height
|
|
95
|
+
} = themeTokens;
|
|
96
|
+
const content = barHeight && barHeight !== height ? /*#__PURE__*/_jsx(View, {
|
|
97
|
+
style: selectBarWrapperStyles(themeTokens),
|
|
98
|
+
children: children
|
|
99
|
+
}) : children;
|
|
75
100
|
return /*#__PURE__*/_jsx(ProgressContext.Provider, {
|
|
76
101
|
value: {
|
|
77
102
|
layers
|
|
@@ -80,7 +105,7 @@ const Progress = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
80
105
|
ref: ref,
|
|
81
106
|
style: [staticStyles.progressContainer, selectProgressStyles(themeTokens)],
|
|
82
107
|
...selectProps(rest),
|
|
83
|
-
children:
|
|
108
|
+
children: content
|
|
84
109
|
})
|
|
85
110
|
});
|
|
86
111
|
});
|