@telus-uds/components-base 1.47.0 → 1.48.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 CHANGED
@@ -1,12 +1,26 @@
1
1
  # Change Log - @telus-uds/components-base
2
2
 
3
- This log was last generated on Fri, 02 Jun 2023 00:27:36 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 06 Jun 2023 20:37:42 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.48.0
8
+
9
+ Tue, 06 Jun 2023 20:37:42 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - add new story for 'ButtonDropdown' (kyle.king2@telus.com)
14
+ - change animation to skeleton component (mauricio.batresmontejo@telus.com)
15
+ - Bump @telus-uds/system-theme-tokens to v2.30.0
16
+
17
+ ### Patches
18
+
19
+ - Fix an issue where `Button` may not align as expected in a flex container (shahzaibkhalidmalik@outlook.com)
20
+
7
21
  ## 1.47.0
8
22
 
9
- Fri, 02 Jun 2023 00:27:36 GMT
23
+ Fri, 02 Jun 2023 00:34:55 GMT
10
24
 
11
25
  ### Minor changes
12
26
 
@@ -307,7 +307,6 @@
307
307
  "color": "color",
308
308
  "lineHeight": "lineHeight",
309
309
  "textAlign": "flexJustifyContent",
310
- "alignSelf": "flexAlign",
311
310
  "fontName": "fontName",
312
311
  "fontWeight": "fontWeight",
313
312
  "backgroundColor": "color",
@@ -1683,6 +1682,8 @@
1683
1682
  },
1684
1683
  "Skeleton": {
1685
1684
  "color": "color",
1685
+ "secondColor": "color",
1686
+ "animationDuration": "integer",
1686
1687
  "size": "size",
1687
1688
  "radius": "radius",
1688
1689
  "baseWidth": "size",
@@ -9186,6 +9187,8 @@
9186
9187
  "name": "custom",
9187
9188
  "raw": {
9188
9189
  "color": "color",
9190
+ "secondColor": "color",
9191
+ "animationDuration": "integer",
9189
9192
  "size": "size",
9190
9193
  "radius": "radius",
9191
9194
  "baseWidth": "size",
@@ -10873,7 +10876,6 @@
10873
10876
  "color": "color",
10874
10877
  "lineHeight": "lineHeight",
10875
10878
  "textAlign": "flexJustifyContent",
10876
- "alignSelf": "flexAlign",
10877
10879
  "fontName": "fontName",
10878
10880
  "fontWeight": "fontWeight",
10879
10881
  "backgroundColor": "color",
@@ -11072,7 +11074,6 @@
11072
11074
  "color": "color",
11073
11075
  "lineHeight": "lineHeight",
11074
11076
  "textAlign": "flexJustifyContent",
11075
- "alignSelf": "flexAlign",
11076
11077
  "fontName": "fontName",
11077
11078
  "fontWeight": "fontWeight",
11078
11079
  "backgroundColor": "color",
@@ -11498,7 +11499,6 @@
11498
11499
  "color": "color",
11499
11500
  "lineHeight": "lineHeight",
11500
11501
  "textAlign": "flexJustifyContent",
11501
- "alignSelf": "flexAlign",
11502
11502
  "fontName": "fontName",
11503
11503
  "fontWeight": "fontWeight",
11504
11504
  "backgroundColor": "color",
@@ -45,7 +45,6 @@ const getOuterBorderOffset = _ref => {
45
45
 
46
46
  const selectOuterContainerStyles = _ref2 => {
47
47
  let {
48
- alignSelf,
49
48
  opacity,
50
49
  outerBorderColor,
51
50
  outerBorderWidth,
@@ -53,8 +52,11 @@ const selectOuterContainerStyles = _ref2 => {
53
52
  borderRadius,
54
53
  outerBackgroundColor
55
54
  } = _ref2;
56
- return {
57
- alignSelf,
55
+ return { ..._Platform.default.select({
56
+ native: {
57
+ alignSelf: 'flex-start'
58
+ }
59
+ }),
58
60
  backgroundColor: outerBackgroundColor,
59
61
  opacity,
60
62
  ...(0, _ThemeProvider.applyOuterBorder)({
@@ -221,6 +223,7 @@ const selectWebOnlyStyles = (inactive, themeTokens, _ref8) => {
221
223
  web: {
222
224
  // if it would overflow the container, wraps instead
223
225
  maxWidth: `calc(100% + ${getOuterBorderOffset(themeTokens) * 2}px)`,
226
+ width: 'fit-content',
224
227
  outline: 'none',
225
228
  // removes the default browser :focus outline
226
229
  ...(0, _utils.getCursorStyle)(inactive, accessibilityRole)
@@ -100,11 +100,18 @@ const Skeleton = /*#__PURE__*/(0, _react.forwardRef)((_ref5, ref) => {
100
100
  }
101
101
  } : // Size by an index on the spacing scale (getting default index from theme if none provided)
102
102
  sizeIndex || themeTokens.size;
103
- const skeletonHeight = (0, _utils.useSpacingScale)(spacingScaleValue);
104
- const nativeAnimation = (0, _useSkeletonNativeAnimation.default)();
103
+ const skeletonHeight = (0, _utils.useSpacingScale)(spacingScaleValue); // Animation color and animation duration
104
+
105
+ const {
106
+ secondColor,
107
+ animationDuration
108
+ } = themeTokens;
109
+ const nativeAnimation = (0, _useSkeletonNativeAnimation.default)({
110
+ animationDuration
111
+ });
105
112
 
106
113
  const getAnimationBasedOnPlatform = () => {
107
- const animation = _Platform.default.OS === 'web' ? _skeletonWebAnimation.default : nativeAnimation; // We must pass the animation styles through `StyleSheet.create`
114
+ const animation = _Platform.default.OS === 'web' ? (0, _skeletonWebAnimation.default)(secondColor, animationDuration) : nativeAnimation; // We must pass the animation styles through `StyleSheet.create`
108
115
  // @see https://github.com/necolas/react-native-web/issues/2387
109
116
 
110
117
  const styles = _StyleSheet.default.create({
@@ -3,10 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.OPACITY_STOP = exports.DEFAULT_OPACITY = exports.ANIMATION_DURATION = void 0;
6
+ exports.OPACITY_STOP = exports.DEFAULT_OPACITY = void 0;
7
7
  const DEFAULT_OPACITY = 1;
8
8
  exports.DEFAULT_OPACITY = DEFAULT_OPACITY;
9
9
  const OPACITY_STOP = 0.4;
10
- exports.OPACITY_STOP = OPACITY_STOP;
11
- const ANIMATION_DURATION = 1500;
12
- exports.ANIMATION_DURATION = ANIMATION_DURATION;
10
+ exports.OPACITY_STOP = OPACITY_STOP;
@@ -5,23 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _skeleton = require("./skeleton.constant");
9
-
10
- var _default = {
11
- animationDuration: `${_skeleton.ANIMATION_DURATION}ms`,
12
- animationTimingFunction: 'ease-in-out',
13
- animationDelay: '0.5s',
14
- animationIterationCount: 'infinite',
15
- animationKeyframes: {
16
- '0%': {
17
- opacity: _skeleton.DEFAULT_OPACITY
18
- },
19
- '50%': {
20
- opacity: _skeleton.OPACITY_STOP
21
- },
22
- '100%': {
23
- opacity: _skeleton.DEFAULT_OPACITY
8
+ const skeletonWebAnimation = (secondColor, animationTime) => {
9
+ return {
10
+ animationDuration: `${animationTime}ms`,
11
+ animationTimingFunction: 'ease-in-out',
12
+ animationDelay: '0.5s',
13
+ animationIterationCount: 'infinite',
14
+ animationKeyframes: {
15
+ '50%': {
16
+ backgroundColor: secondColor
17
+ }
24
18
  }
25
- }
19
+ };
26
20
  };
21
+
22
+ var _default = skeletonWebAnimation;
27
23
  exports.default = _default;
@@ -15,16 +15,21 @@ var _skeleton = require("./skeleton.constant");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- const useSkeletonNativeAnimation = () => {
18
+ const useSkeletonNativeAnimation = _ref => {
19
+ let {
20
+ animationDuration
21
+ } = _ref;
19
22
  const fadeAnimation = (0, _react.useRef)(new _Animated.default.Value(_skeleton.DEFAULT_OPACITY)).current;
23
+ /* eslint-disable react-hooks/exhaustive-deps */
24
+
20
25
  (0, _react.useEffect)(() => {
21
26
  const fade = _Animated.default.sequence([_Animated.default.timing(fadeAnimation, {
22
27
  toValue: _skeleton.OPACITY_STOP,
23
- duration: _skeleton.ANIMATION_DURATION,
28
+ duration: animationDuration,
24
29
  useNativeDriver: _Platform.default.OS !== 'web'
25
30
  }), _Animated.default.timing(fadeAnimation, {
26
31
  toValue: _skeleton.DEFAULT_OPACITY,
27
- duration: _skeleton.ANIMATION_DURATION,
32
+ duration: animationDuration,
28
33
  useNativeDriver: _Platform.default.OS !== 'web'
29
34
  })]);
30
35
 
@@ -21,7 +21,6 @@ const getOuterBorderOffset = _ref => {
21
21
 
22
22
  const selectOuterContainerStyles = _ref2 => {
23
23
  let {
24
- alignSelf,
25
24
  opacity,
26
25
  outerBorderColor,
27
26
  outerBorderWidth,
@@ -29,8 +28,11 @@ const selectOuterContainerStyles = _ref2 => {
29
28
  borderRadius,
30
29
  outerBackgroundColor
31
30
  } = _ref2;
32
- return {
33
- alignSelf,
31
+ return { ...Platform.select({
32
+ native: {
33
+ alignSelf: 'flex-start'
34
+ }
35
+ }),
34
36
  backgroundColor: outerBackgroundColor,
35
37
  opacity,
36
38
  ...applyOuterBorder({
@@ -197,6 +199,7 @@ const selectWebOnlyStyles = (inactive, themeTokens, _ref8) => {
197
199
  web: {
198
200
  // if it would overflow the container, wraps instead
199
201
  maxWidth: `calc(100% + ${getOuterBorderOffset(themeTokens) * 2}px)`,
202
+ width: 'fit-content',
200
203
  outline: 'none',
201
204
  // removes the default browser :focus outline
202
205
  ...getCursorStyle(inactive, accessibilityRole)
@@ -75,11 +75,18 @@ const Skeleton = /*#__PURE__*/forwardRef((_ref5, ref) => {
75
75
  }
76
76
  } : // Size by an index on the spacing scale (getting default index from theme if none provided)
77
77
  sizeIndex || themeTokens.size;
78
- const skeletonHeight = useSpacingScale(spacingScaleValue);
79
- const nativeAnimation = useSkeletonNativeAnimation();
78
+ const skeletonHeight = useSpacingScale(spacingScaleValue); // Animation color and animation duration
79
+
80
+ const {
81
+ secondColor,
82
+ animationDuration
83
+ } = themeTokens;
84
+ const nativeAnimation = useSkeletonNativeAnimation({
85
+ animationDuration
86
+ });
80
87
 
81
88
  const getAnimationBasedOnPlatform = () => {
82
- const animation = Platform.OS === 'web' ? skeletonWebAnimation : nativeAnimation; // We must pass the animation styles through `StyleSheet.create`
89
+ const animation = Platform.OS === 'web' ? skeletonWebAnimation(secondColor, animationDuration) : nativeAnimation; // We must pass the animation styles through `StyleSheet.create`
83
90
  // @see https://github.com/necolas/react-native-web/issues/2387
84
91
 
85
92
  const styles = StyleSheet.create({
@@ -1,3 +1,2 @@
1
1
  export const DEFAULT_OPACITY = 1;
2
- export const OPACITY_STOP = 0.4;
3
- export const ANIMATION_DURATION = 1500;
2
+ export const OPACITY_STOP = 0.4;
@@ -1,18 +1,15 @@
1
- import { ANIMATION_DURATION, DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant';
2
- export default {
3
- animationDuration: `${ANIMATION_DURATION}ms`,
4
- animationTimingFunction: 'ease-in-out',
5
- animationDelay: '0.5s',
6
- animationIterationCount: 'infinite',
7
- animationKeyframes: {
8
- '0%': {
9
- opacity: DEFAULT_OPACITY
10
- },
11
- '50%': {
12
- opacity: OPACITY_STOP
13
- },
14
- '100%': {
15
- opacity: DEFAULT_OPACITY
1
+ const skeletonWebAnimation = (secondColor, animationTime) => {
2
+ return {
3
+ animationDuration: `${animationTime}ms`,
4
+ animationTimingFunction: 'ease-in-out',
5
+ animationDelay: '0.5s',
6
+ animationIterationCount: 'infinite',
7
+ animationKeyframes: {
8
+ '50%': {
9
+ backgroundColor: secondColor
10
+ }
16
11
  }
17
- }
18
- };
12
+ };
13
+ };
14
+
15
+ export default skeletonWebAnimation;
@@ -1,18 +1,23 @@
1
1
  import { useEffect, useRef } from 'react';
2
2
  import Animated from "react-native-web/dist/exports/Animated";
3
3
  import Platform from "react-native-web/dist/exports/Platform";
4
- import { ANIMATION_DURATION, DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant';
4
+ import { DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant';
5
5
 
6
- const useSkeletonNativeAnimation = () => {
6
+ const useSkeletonNativeAnimation = _ref => {
7
+ let {
8
+ animationDuration
9
+ } = _ref;
7
10
  const fadeAnimation = useRef(new Animated.Value(DEFAULT_OPACITY)).current;
11
+ /* eslint-disable react-hooks/exhaustive-deps */
12
+
8
13
  useEffect(() => {
9
14
  const fade = Animated.sequence([Animated.timing(fadeAnimation, {
10
15
  toValue: OPACITY_STOP,
11
- duration: ANIMATION_DURATION,
16
+ duration: animationDuration,
12
17
  useNativeDriver: Platform.OS !== 'web'
13
18
  }), Animated.timing(fadeAnimation, {
14
19
  toValue: DEFAULT_OPACITY,
15
- duration: ANIMATION_DURATION,
20
+ duration: animationDuration,
16
21
  useNativeDriver: Platform.OS !== 'web'
17
22
  })]);
18
23
  Animated.loop(fade).start();
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "@floating-ui/react-native": "^0.8.1",
12
12
  "@gorhom/portal": "^1.0.14",
13
13
  "@telus-uds/system-constants": "^1.2.1",
14
- "@telus-uds/system-theme-tokens": "^2.29.0",
14
+ "@telus-uds/system-theme-tokens": "^2.30.0",
15
15
  "airbnb-prop-types": "^2.16.0",
16
16
  "lodash.debounce": "^4.0.8",
17
17
  "lodash.merge": "^4.6.2",
@@ -72,5 +72,5 @@
72
72
  "standard-engine": {
73
73
  "skip": true
74
74
  },
75
- "version": "1.47.0"
75
+ "version": "1.48.0"
76
76
  }
@@ -30,7 +30,6 @@ const getOuterBorderOffset = ({ outerBorderGap = 0, outerBorderWidth = 0 }) =>
30
30
  outerBorderGap + outerBorderWidth
31
31
 
32
32
  const selectOuterContainerStyles = ({
33
- alignSelf,
34
33
  opacity,
35
34
  outerBorderColor,
36
35
  outerBorderWidth,
@@ -38,7 +37,11 @@ const selectOuterContainerStyles = ({
38
37
  borderRadius,
39
38
  outerBackgroundColor
40
39
  }) => ({
41
- alignSelf,
40
+ ...Platform.select({
41
+ native: {
42
+ alignSelf: 'flex-start'
43
+ }
44
+ }),
42
45
  backgroundColor: outerBackgroundColor,
43
46
  opacity,
44
47
  ...applyOuterBorder({
@@ -162,6 +165,7 @@ const selectWebOnlyStyles = (inactive, themeTokens, { accessibilityRole }) => {
162
165
  web: {
163
166
  // if it would overflow the container, wraps instead
164
167
  maxWidth: `calc(100% + ${getOuterBorderOffset(themeTokens) * 2}px)`,
168
+ width: 'fit-content',
165
169
  outline: 'none', // removes the default browser :focus outline
166
170
  ...getCursorStyle(inactive, accessibilityRole)
167
171
  },
@@ -63,10 +63,17 @@ const Skeleton = forwardRef(
63
63
  : // Size by an index on the spacing scale (getting default index from theme if none provided)
64
64
  sizeIndex || themeTokens.size
65
65
  const skeletonHeight = useSpacingScale(spacingScaleValue)
66
- const nativeAnimation = useSkeletonNativeAnimation()
66
+
67
+ // Animation color and animation duration
68
+ const { secondColor, animationDuration } = themeTokens
69
+
70
+ const nativeAnimation = useSkeletonNativeAnimation({ animationDuration })
67
71
 
68
72
  const getAnimationBasedOnPlatform = () => {
69
- const animation = Platform.OS === 'web' ? skeletonWebAnimation : nativeAnimation
73
+ const animation =
74
+ Platform.OS === 'web'
75
+ ? skeletonWebAnimation(secondColor, animationDuration)
76
+ : nativeAnimation
70
77
  // We must pass the animation styles through `StyleSheet.create`
71
78
  // @see https://github.com/necolas/react-native-web/issues/2387
72
79
  const styles = StyleSheet.create({ animation })
@@ -1,3 +1,2 @@
1
1
  export const DEFAULT_OPACITY = 1
2
2
  export const OPACITY_STOP = 0.4
3
- export const ANIMATION_DURATION = 1500
@@ -1,13 +1,13 @@
1
- import { ANIMATION_DURATION, DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant'
2
-
3
- export default {
4
- animationDuration: `${ANIMATION_DURATION}ms`,
5
- animationTimingFunction: 'ease-in-out',
6
- animationDelay: '0.5s',
7
- animationIterationCount: 'infinite',
8
- animationKeyframes: {
9
- '0%': { opacity: DEFAULT_OPACITY },
10
- '50%': { opacity: OPACITY_STOP },
11
- '100%': { opacity: DEFAULT_OPACITY }
1
+ const skeletonWebAnimation = (secondColor, animationTime) => {
2
+ return {
3
+ animationDuration: `${animationTime}ms`,
4
+ animationTimingFunction: 'ease-in-out',
5
+ animationDelay: '0.5s',
6
+ animationIterationCount: 'infinite',
7
+ animationKeyframes: {
8
+ '50%': { backgroundColor: secondColor }
9
+ }
12
10
  }
13
11
  }
12
+
13
+ export default skeletonWebAnimation
@@ -1,20 +1,21 @@
1
1
  import { useEffect, useRef } from 'react'
2
2
  import { Animated, Platform } from 'react-native'
3
- import { ANIMATION_DURATION, DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant'
3
+ import { DEFAULT_OPACITY, OPACITY_STOP } from './skeleton.constant'
4
4
 
5
- const useSkeletonNativeAnimation = () => {
5
+ const useSkeletonNativeAnimation = ({ animationDuration }) => {
6
6
  const fadeAnimation = useRef(new Animated.Value(DEFAULT_OPACITY)).current
7
7
 
8
+ /* eslint-disable react-hooks/exhaustive-deps */
8
9
  useEffect(() => {
9
10
  const fade = Animated.sequence([
10
11
  Animated.timing(fadeAnimation, {
11
12
  toValue: OPACITY_STOP,
12
- duration: ANIMATION_DURATION,
13
+ duration: animationDuration,
13
14
  useNativeDriver: Platform.OS !== 'web'
14
15
  }),
15
16
  Animated.timing(fadeAnimation, {
16
17
  toValue: DEFAULT_OPACITY,
17
- duration: ANIMATION_DURATION,
18
+ duration: animationDuration,
18
19
  useNativeDriver: Platform.OS !== 'web'
19
20
  })
20
21
  ])