@telus-uds/components-community.content-card 1.4.0 → 2.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 ADDED
@@ -0,0 +1,22 @@
1
+ const path = require('path')
2
+ const base = require('../../../../eslintrc.base.cjs')
3
+
4
+ base.rules['import/no-extraneous-dependencies'] = [
5
+ 'error',
6
+ { packageDir: [__dirname, path.join(__dirname, '../..')] }
7
+ ]
8
+
9
+ base.settings = {
10
+ ...base.settings,
11
+ 'import/resolver': {
12
+ node: {
13
+ ...base.settings?.['import/resolver']?.node,
14
+ moduleDirectory: [
15
+ path.join(__dirname, '../../node_modules'),
16
+ path.join(__dirname, '../../../../node_modules')
17
+ ]
18
+ }
19
+ }
20
+ }
21
+
22
+ module.exports = base
package/CHANGELOG.md CHANGED
@@ -1,12 +1,22 @@
1
1
  # Change Log - @telus-uds/components-community.content-card
2
2
 
3
- This log was last generated on Thu, 31 Oct 2024 05:02:44 GMT and should not be manually modified.
3
+ <!-- This log was last generated on Fri, 22 Nov 2024 23:40:08 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.0.0
8
+
9
+ Fri, 22 Nov 2024 23:40:08 GMT
10
+
11
+ ### Major changes
12
+
13
+ - Upgrade `react-native` and many other dependencies and refactor to ESM-only builds (shahzaibkhalidmalik@outlook.com)
14
+ - Bump @telus-uds/components-base to v1.97.1
15
+ - Bump @telus-uds/system-theme-tokens to v3.0.0
16
+
7
17
  ## 1.4.0
8
18
 
9
- Thu, 31 Oct 2024 05:02:44 GMT
19
+ Thu, 31 Oct 2024 05:09:13 GMT
10
20
 
11
21
  ### Minor changes
12
22
 
@@ -0,0 +1,4 @@
1
+ const baseConfig = require('../../../../babel.config.base.cjs')
2
+ const name = require('./package.json').name.split('@telus-uds/').pop()
3
+
4
+ module.exports = baseConfig({ name })
@@ -0,0 +1,24 @@
1
+ const preset = require('react-native/jest-preset')
2
+ const name = require('./package.json').name.split('@telus-uds/').pop()
3
+
4
+ module.exports = {
5
+ haste: preset.haste,
6
+ displayName: {
7
+ name,
8
+ color: 'blue'
9
+ },
10
+ setupFiles: preset.setupFiles,
11
+ transform: {
12
+ '.(js|jsx)$': ['babel-jest', { cwd: __dirname }]
13
+ },
14
+ setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect'],
15
+ moduleNameMapper: {
16
+ '.+.(otf|svg|png|jpg)$': 'identity-obj-proxy'
17
+ },
18
+ testMatch: ['<rootDir>/__tests__/**/*.test.js?(x)'],
19
+ transformIgnorePatterns: [
20
+ 'node_modules/(?!(jest-)?react-native|@react-native|@react-native-community|react-native-web|@react-native-picker)'
21
+ ],
22
+ // Count everything in src when calculating coverage
23
+ collectCoverageFrom: ['src/*.{js,jsx}']
24
+ }
@@ -1,18 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.styles = exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _componentsBase = require("@telus-uds/components-base");
10
- var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
11
- var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
12
- var _ImageBackground = _interopRequireDefault(require("react-native-web/dist/cjs/exports/ImageBackground"));
13
- var _jsxRuntime = require("react/jsx-runtime");
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
- const styles = _StyleSheet.default.create({
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Typography, Spacer, ChevronLink, PressableCardBase, selectSystemProps, hrefAttrsProp, withLinkRouter, a11yProps, focusHandlerProps, useThemeTokensCallback, useViewport, useThemeTokens, Box, viewProps } from '@telus-uds/components-base';
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import View from "react-native-web/dist/exports/View";
6
+ import ImageBackground from "react-native-web/dist/exports/ImageBackground";
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ export const styles = StyleSheet.create({
16
9
  rowReverse: {
17
10
  flexDirection: 'row-reverse'
18
11
  },
@@ -29,9 +22,8 @@ const styles = _StyleSheet.default.create({
29
22
  });
30
23
 
31
24
  // Passes React Native-oriented system props through UDS PressableCardBase
32
- exports.styles = styles;
33
- const [selectProps, selectedSystemPropTypes] = (0, _componentsBase.selectSystemProps)([_componentsBase.a11yProps, _componentsBase.focusHandlerProps, _componentsBase.viewProps]);
34
- const ContentCard = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
25
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, viewProps]);
26
+ const ContentCard = /*#__PURE__*/React.forwardRef((_ref, ref) => {
35
27
  let {
36
28
  title,
37
29
  content,
@@ -46,24 +38,24 @@ const ContentCard = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
46
38
  tokens,
47
39
  ...rest
48
40
  } = _ref;
49
- const viewport = (0, _componentsBase.useViewport)();
41
+ const viewport = useViewport();
50
42
  const innerContainerStyle = isContentOnRight ? [styles.innerContainer, styles.rowReverse] : styles.innerContainer;
51
- const generalTokens = (0, _componentsBase.useThemeTokens)('ContentCard', tokens);
52
- const getTokens = (0, _componentsBase.useThemeTokensCallback)('ContentCard', tokens);
53
- const cardTokens = (0, _componentsBase.useThemeTokens)('Card', tokens, {}, {
43
+ const generalTokens = useThemeTokens('ContentCard', tokens);
44
+ const getTokens = useThemeTokensCallback('ContentCard', tokens);
45
+ const cardTokens = useThemeTokens('Card', tokens, {}, {
54
46
  viewport
55
47
  });
56
48
  const {
57
49
  hrefAttrs,
58
50
  rest: unusedRest
59
- } = _componentsBase.hrefAttrsProp.bundle(rest);
51
+ } = hrefAttrsProp.bundle(rest);
60
52
  const getPressableCardTokens = cardState => {
61
53
  return {
62
54
  ...cardTokens,
63
55
  ...getTokens(cardState)
64
56
  };
65
57
  };
66
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.PressableCardBase, {
58
+ return /*#__PURE__*/_jsx(PressableCardBase, {
67
59
  ref: ref,
68
60
  onPress: onPress,
69
61
  href: href,
@@ -77,7 +69,7 @@ const ContentCard = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
77
69
 
78
70
  // Stop content jumping around as border size changes
79
71
  const borderOffset = borderWidth - generalTokens.borderWidth;
80
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Box, {
72
+ return /*#__PURE__*/_jsx(Box, {
81
73
  horizontal: {
82
74
  xs: 4,
83
75
  lg: 5,
@@ -92,31 +84,31 @@ const ContentCard = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
92
84
  subtract: borderOffset
93
85
  }
94
86
  },
95
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
87
+ children: /*#__PURE__*/_jsxs(View, {
96
88
  style: innerContainerStyle,
97
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
89
+ children: [/*#__PURE__*/_jsxs(View, {
98
90
  style: styles.informationContainer,
99
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
91
+ children: [/*#__PURE__*/_jsx(Typography, {
100
92
  heading: "h3",
101
93
  variant: {
102
94
  bold: true,
103
95
  colour: 'brand'
104
96
  },
105
97
  children: title
106
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Spacer, {
98
+ }), /*#__PURE__*/_jsx(Spacer, {
107
99
  space: 1
108
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Typography, {
100
+ }), /*#__PURE__*/_jsx(Typography, {
109
101
  variant: {
110
102
  size: 'small'
111
103
  },
112
104
  children: content
113
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Spacer, {
105
+ }), /*#__PURE__*/_jsx(Spacer, {
114
106
  space: 3
115
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.ChevronLink, {
107
+ }), /*#__PURE__*/_jsx(ChevronLink, {
116
108
  disabled: true,
117
109
  children: linkText
118
110
  })]
119
- }), customImage || /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImageBackground.default, {
111
+ }), customImage || /*#__PURE__*/_jsx(ImageBackground, {
120
112
  source: imageSrc
121
113
  // eslint-disable-next-line react-native/no-inline-styles
122
114
  ,
@@ -139,43 +131,42 @@ ContentCard.propTypes = {
139
131
  /**
140
132
  * The URL to be navigated to.
141
133
  */
142
- href: _propTypes.default.string,
134
+ href: PropTypes.string,
143
135
  /**
144
136
  * Text stating the title or headline.
145
137
  */
146
- title: _propTypes.default.string.isRequired,
138
+ title: PropTypes.string.isRequired,
147
139
  /**
148
140
  * Text giving a short content of the card. One paragraph of plain text.
149
141
  */
150
- content: _propTypes.default.string.isRequired,
142
+ content: PropTypes.string.isRequired,
151
143
  /**
152
144
  * Text for the ChevronLink.
153
145
  */
154
- linkText: _propTypes.default.string.isRequired,
146
+ linkText: PropTypes.string.isRequired,
155
147
  /**
156
148
  * Optional function to be called on press e.g. for within-page navigation.
157
149
  */
158
- onPress: _propTypes.default.func,
150
+ onPress: PropTypes.func,
159
151
  /**
160
152
  * Src of the Image.
161
153
  */
162
- imageSrc: _propTypes.default.string,
154
+ imageSrc: PropTypes.string,
163
155
  /**
164
156
  * Height of the Image.
165
157
  */
166
- imageHeight: _propTypes.default.number,
158
+ imageHeight: PropTypes.number,
167
159
  /**
168
160
  * Width of the Image.
169
161
  */
170
- imageWidth: _propTypes.default.number,
162
+ imageWidth: PropTypes.number,
171
163
  /**
172
164
  * Custom Image to be used instead of the default image.
173
165
  */
174
- customImage: _propTypes.default.node,
166
+ customImage: PropTypes.node,
175
167
  /**
176
168
  * Controls if the content is on the right side of the image.
177
169
  */
178
- isContentOnRight: _propTypes.default.bool
170
+ isContentOnRight: PropTypes.bool
179
171
  };
180
- var _default = (0, _componentsBase.withLinkRouter)(ContentCard);
181
- exports.default = _default;
172
+ export default withLinkRouter(ContentCard);
package/lib/index.js CHANGED
@@ -1,16 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "ContentCard", {
7
- enumerable: true,
8
- get: function () {
9
- return _ContentCard.default;
10
- }
11
- });
12
- exports.default = void 0;
13
- var _ContentCard = _interopRequireDefault(require("./ContentCard"));
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
- var _default = _ContentCard.default;
16
- exports.default = _default;
1
+ import ContentCard from './ContentCard';
2
+ export { default as ContentCard } from './ContentCard';
3
+ export default ContentCard;
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "author": "TELUS Digital",
3
+ "type": "module",
3
4
  "browserslist": [
4
5
  "extends @telus-uds/browserslist-config"
5
6
  ],
6
7
  "dependencies": {
7
- "@telus-uds/components-base": "^1.97.0",
8
- "prop-types": "^15.7.2"
8
+ "prop-types": "^15.7.2",
9
+ "react-native": "^0.74.5",
10
+ "@telus-uds/components-base": "^1.97.1"
9
11
  },
10
12
  "devDependencies": {
11
13
  "@telus-uds/browserslist-config": "^1.0.5",
12
- "@telus-uds/system-theme-tokens": "^2.66.0",
14
+ "@telus-uds/system-theme-tokens": "^3.0.0",
13
15
  "@testing-library/react-native": "11.0.0",
14
16
  "babel-plugin-react-native-web": "^0.17.0",
15
17
  "babel-plugin-styled-components": "^2.0.6",
@@ -19,14 +21,19 @@
19
21
  "license": "MIT",
20
22
  "name": "@telus-uds/components-community.content-card",
21
23
  "peerDependencies": {
22
- "react": "^17.0.2 || ^18.0.0",
23
- "react-dom": "^17.0.2 || ^18.0.0",
24
- "react-native": "*",
25
- "react-native-web": "~0.17.7 || ~0.18.7"
24
+ "react": "^18.2.0",
25
+ "react-dom": "^18.2.0",
26
+ "react-native": "^0.74.5",
27
+ "react-native-web": "^0.19.10"
26
28
  },
27
29
  "main": "lib/index.js",
28
- "module": "lib-module/index.js",
29
- "react-native": "src/index.js",
30
+ "module": "lib/index.js",
31
+ "exports": {
32
+ ".": {
33
+ "import": "./lib/index.js",
34
+ "default": "./lib/index.js"
35
+ }
36
+ },
30
37
  "repository": {
31
38
  "type": "git",
32
39
  "url": "git+https://github.com/telus/universal-design-system.git"
@@ -36,13 +43,11 @@
36
43
  "lint": "telus-standard",
37
44
  "lint:fix": "telus-standard --fix",
38
45
  "test": "jest",
39
- "build:main": "babel src -d lib",
40
- "build:module": "babel src -d lib-module --env-name module",
41
- "build": "npm run build:main && npm run build:module"
46
+ "build": "babel src -d lib --env-name module"
42
47
  },
43
48
  "sideEffects": false,
44
49
  "standard-engine": {
45
50
  "skip": true
46
51
  },
47
- "version": "1.4.0"
52
+ "version": "2.0.0"
48
53
  }
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "ContentCard", {
7
- enumerable: true,
8
- get: function () {
9
- return _ContentCard.default;
10
- }
11
- });
12
- exports.default = void 0;
13
- var _ContentCard = _interopRequireDefault(require("./ContentCard"));
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
- var _default = _ContentCard.default;
16
- exports.default = _default;
@@ -1,173 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Typography, Spacer, ChevronLink, PressableCardBase, selectSystemProps, hrefAttrsProp, withLinkRouter, a11yProps, focusHandlerProps, useThemeTokensCallback, useViewport, useThemeTokens, Box, viewProps } from '@telus-uds/components-base';
4
- import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
- import View from "react-native-web/dist/exports/View";
6
- import ImageBackground from "react-native-web/dist/exports/ImageBackground";
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- import { jsxs as _jsxs } from "react/jsx-runtime";
9
- export const styles = StyleSheet.create({
10
- rowReverse: {
11
- flexDirection: 'row-reverse'
12
- },
13
- innerContainer: {
14
- display: 'flex',
15
- flexDirection: 'row',
16
- justifyContent: 'space-between',
17
- alignItems: 'center',
18
- width: 'auto'
19
- },
20
- informationContainer: {
21
- width: '65%'
22
- }
23
- });
24
-
25
- // Passes React Native-oriented system props through UDS PressableCardBase
26
- const [selectProps, selectedSystemPropTypes] = selectSystemProps([a11yProps, focusHandlerProps, viewProps]);
27
- const ContentCard = /*#__PURE__*/React.forwardRef((_ref, ref) => {
28
- let {
29
- title,
30
- content,
31
- linkText,
32
- onPress,
33
- href,
34
- customImage,
35
- imageSrc,
36
- imageHeight,
37
- imageWidth,
38
- isContentOnRight = false,
39
- tokens,
40
- ...rest
41
- } = _ref;
42
- const viewport = useViewport();
43
- const innerContainerStyle = isContentOnRight ? [styles.innerContainer, styles.rowReverse] : styles.innerContainer;
44
- const generalTokens = useThemeTokens('ContentCard', tokens);
45
- const getTokens = useThemeTokensCallback('ContentCard', tokens);
46
- const cardTokens = useThemeTokens('Card', tokens, {}, {
47
- viewport
48
- });
49
- const {
50
- hrefAttrs,
51
- rest: unusedRest
52
- } = hrefAttrsProp.bundle(rest);
53
- const getPressableCardTokens = cardState => {
54
- return {
55
- ...cardTokens,
56
- ...getTokens(cardState)
57
- };
58
- };
59
- return /*#__PURE__*/_jsx(PressableCardBase, {
60
- ref: ref,
61
- onPress: onPress,
62
- href: href,
63
- hrefAttrs: hrefAttrs,
64
- tokens: getPressableCardTokens,
65
- ...selectProps(unusedRest),
66
- children: cardState => {
67
- const {
68
- borderWidth
69
- } = getPressableCardTokens(cardState);
70
-
71
- // Stop content jumping around as border size changes
72
- const borderOffset = borderWidth - generalTokens.borderWidth;
73
- return /*#__PURE__*/_jsx(Box, {
74
- horizontal: {
75
- xs: 4,
76
- lg: 5,
77
- options: {
78
- subtract: borderOffset
79
- }
80
- },
81
- vertical: {
82
- xs: 5,
83
- lg: 7,
84
- options: {
85
- subtract: borderOffset
86
- }
87
- },
88
- children: /*#__PURE__*/_jsxs(View, {
89
- style: innerContainerStyle,
90
- children: [/*#__PURE__*/_jsxs(View, {
91
- style: styles.informationContainer,
92
- children: [/*#__PURE__*/_jsx(Typography, {
93
- heading: "h3",
94
- variant: {
95
- bold: true,
96
- colour: 'brand'
97
- },
98
- children: title
99
- }), /*#__PURE__*/_jsx(Spacer, {
100
- space: 1
101
- }), /*#__PURE__*/_jsx(Typography, {
102
- variant: {
103
- size: 'small'
104
- },
105
- children: content
106
- }), /*#__PURE__*/_jsx(Spacer, {
107
- space: 3
108
- }), /*#__PURE__*/_jsx(ChevronLink, {
109
- disabled: true,
110
- children: linkText
111
- })]
112
- }), customImage || /*#__PURE__*/_jsx(ImageBackground, {
113
- source: imageSrc
114
- // eslint-disable-next-line react-native/no-inline-styles
115
- ,
116
- style: {
117
- flex: 1,
118
- aspectRatio: imageWidth / imageHeight,
119
- maxHeight: imageHeight,
120
- maxWidth: imageWidth
121
- },
122
- resizeMode: "contain"
123
- })]
124
- })
125
- });
126
- }
127
- });
128
- });
129
- ContentCard.displayName = 'ContentCard';
130
- ContentCard.propTypes = {
131
- ...selectedSystemPropTypes,
132
- /**
133
- * The URL to be navigated to.
134
- */
135
- href: PropTypes.string,
136
- /**
137
- * Text stating the title or headline.
138
- */
139
- title: PropTypes.string.isRequired,
140
- /**
141
- * Text giving a short content of the card. One paragraph of plain text.
142
- */
143
- content: PropTypes.string.isRequired,
144
- /**
145
- * Text for the ChevronLink.
146
- */
147
- linkText: PropTypes.string.isRequired,
148
- /**
149
- * Optional function to be called on press e.g. for within-page navigation.
150
- */
151
- onPress: PropTypes.func,
152
- /**
153
- * Src of the Image.
154
- */
155
- imageSrc: PropTypes.string,
156
- /**
157
- * Height of the Image.
158
- */
159
- imageHeight: PropTypes.number,
160
- /**
161
- * Width of the Image.
162
- */
163
- imageWidth: PropTypes.number,
164
- /**
165
- * Custom Image to be used instead of the default image.
166
- */
167
- customImage: PropTypes.node,
168
- /**
169
- * Controls if the content is on the right side of the image.
170
- */
171
- isContentOnRight: PropTypes.bool
172
- };
173
- export default withLinkRouter(ContentCard);
@@ -1,3 +0,0 @@
1
- import ContentCard from './ContentCard';
2
- export { default as ContentCard } from './ContentCard';
3
- export default ContentCard;
@@ -1,3 +0,0 @@
1
- import ContentCard from './ContentCard';
2
- export { default as ContentCard } from './ContentCard';
3
- export default ContentCard;
@@ -1,5 +0,0 @@
1
- import ContentCard from './ContentCard'
2
-
3
- export { default as ContentCard } from './ContentCard'
4
-
5
- export default ContentCard