@telus-uds/components-base 1.6.0 → 1.6.1

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.
@@ -1,8 +1,8 @@
1
- @telus-uds/components-base:build: cache hit, replaying output d1359cc1069914c5
2
- @telus-uds/components-base:build: $ yarn build:code && yarn build:docs
3
- @telus-uds/components-base:build: $ yarn build:main && yarn build:module
4
- @telus-uds/components-base:build: $ babel src -d lib
5
- @telus-uds/components-base:build: Successfully compiled 217 files with Babel (8026ms).
6
- @telus-uds/components-base:build: $ babel src -d lib-module --env-name module
7
- @telus-uds/components-base:build: Successfully compiled 217 files with Babel (5098ms).
8
- @telus-uds/components-base:build: $ babel-node --plugins=@nearform/babel-plugin-react-docgen generate-component-docs.js
1
+ @telus-uds/components-base:build: cache hit, replaying output 5b52d282f98ddfb3
2
+ @telus-uds/components-base:build: $ yarn build:code && yarn build:docs
3
+ @telus-uds/components-base:build: $ yarn build:main && yarn build:module
4
+ @telus-uds/components-base:build: $ babel src -d lib
5
+ @telus-uds/components-base:build: Successfully compiled 217 files with Babel (4961ms).
6
+ @telus-uds/components-base:build: $ babel src -d lib-module --env-name module
7
+ @telus-uds/components-base:build: Successfully compiled 217 files with Babel (3447ms).
8
+ @telus-uds/components-base:build: $ babel-node --plugins=@nearform/babel-plugin-react-docgen generate-component-docs.js
@@ -1,13 +1,13 @@
1
- @telus-uds/components-base:lint: cache hit, replaying output 946abc71241dcfa6
2
- @telus-uds/components-base:lint: $ yarn --cwd ../.. lint:path --color packages/components-base
3
- @telus-uds/components-base:lint: $ eslint --ignore-path .gitignore --ext .js,.jsx,.mjs,.cjs --color packages/components-base
4
- @telus-uds/components-base:lint: 
5
- @telus-uds/components-base:lint: /home/runner/work/universal-design-system/universal-design-system/packages/components-base/__tests__/FlexGrid/Col.test.jsx
6
- @telus-uds/components-base:lint:  51:71 warning Expect must have a corresponding matcher call jest/valid-expect
7
- @telus-uds/components-base:lint:  106:71 warning Expect must have a corresponding matcher call jest/valid-expect
8
- @telus-uds/components-base:lint:  155:63 warning Expect must have a corresponding matcher call jest/valid-expect
9
- @telus-uds/components-base:lint:  200:71 warning Expect must have a corresponding matcher call jest/valid-expect
10
- @telus-uds/components-base:lint:  248:71 warning Expect must have a corresponding matcher call jest/valid-expect
11
- @telus-uds/components-base:lint: 
12
- @telus-uds/components-base:lint: ✖ 5 problems (0 errors, 5 warnings)
13
- @telus-uds/components-base:lint: 
1
+ @telus-uds/components-base:lint: cache hit, replaying output 311834e1773df30e
2
+ @telus-uds/components-base:lint: $ yarn --cwd ../.. lint:path --color packages/components-base
3
+ @telus-uds/components-base:lint: $ eslint --ignore-path .gitignore --ext .js,.jsx,.mjs,.cjs --color packages/components-base
4
+ @telus-uds/components-base:lint: 
5
+ @telus-uds/components-base:lint: /home/runner/work/universal-design-system/universal-design-system/packages/components-base/__tests__/FlexGrid/Col.test.jsx
6
+ @telus-uds/components-base:lint:  51:71 warning Expect must have a corresponding matcher call jest/valid-expect
7
+ @telus-uds/components-base:lint:  106:71 warning Expect must have a corresponding matcher call jest/valid-expect
8
+ @telus-uds/components-base:lint:  155:63 warning Expect must have a corresponding matcher call jest/valid-expect
9
+ @telus-uds/components-base:lint:  200:71 warning Expect must have a corresponding matcher call jest/valid-expect
10
+ @telus-uds/components-base:lint:  248:71 warning Expect must have a corresponding matcher call jest/valid-expect
11
+ @telus-uds/components-base:lint: 
12
+ @telus-uds/components-base:lint: ✖ 5 problems (0 errors, 5 warnings)
13
+ @telus-uds/components-base:lint: 
package/CHANGELOG.json CHANGED
@@ -2,7 +2,28 @@
2
2
  "name": "@telus-uds/components-base",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 28 Apr 2022 15:40:15 GMT",
5
+ "date": "Fri, 06 May 2022 15:31:22 GMT",
6
+ "tag": "@telus-uds/components-base_v1.6.1",
7
+ "version": "1.6.1",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "alan.slater@nearform.com",
12
+ "package": "@telus-uds/components-base",
13
+ "commit": "d0967886e4328b789fd5490f068c74fa24379b87",
14
+ "comment": "don't throw if no href/onPress in link/button"
15
+ },
16
+ {
17
+ "author": "ruslan.bredikhin@nearform.com",
18
+ "package": "@telus-uds/components-base",
19
+ "commit": "d0967886e4328b789fd5490f068c74fa24379b87",
20
+ "comment": "fix: allow parsing tokens inherited from multiple components"
21
+ }
22
+ ]
23
+ }
24
+ },
25
+ {
26
+ "date": "Thu, 28 Apr 2022 15:40:29 GMT",
6
27
  "tag": "@telus-uds/components-base_v1.6.0",
7
28
  "version": "1.6.0",
8
29
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,21 @@
1
1
  # Change Log - @telus-uds/components-base
2
2
 
3
- This log was last generated on Thu, 28 Apr 2022 15:40:15 GMT and should not be manually modified.
3
+ This log was last generated on Fri, 06 May 2022 15:31:22 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.6.1
8
+
9
+ Fri, 06 May 2022 15:31:22 GMT
10
+
11
+ ### Patches
12
+
13
+ - don't throw if no href/onPress in link/button (alan.slater@nearform.com)
14
+ - fix: allow parsing tokens inherited from multiple components (ruslan.bredikhin@nearform.com)
15
+
7
16
  ## 1.6.0
8
17
 
9
- Thu, 28 Apr 2022 15:40:15 GMT
18
+ Thu, 28 Apr 2022 15:40:29 GMT
10
19
 
11
20
  ### Minor changes
12
21
 
@@ -8509,7 +8509,29 @@
8509
8509
  "tokens": {
8510
8510
  "type": {
8511
8511
  "name": "custom",
8512
- "raw": "getTokensPropType('ChevronLink', 'Link')"
8512
+ "raw": {
8513
+ "leftIcon": "icon",
8514
+ "rightIcon": "icon",
8515
+ "iconDisplace": "size",
8516
+ "iconSize": "size",
8517
+ "iconSpace": "integer",
8518
+ "textLine": "textLine",
8519
+ "color": "color",
8520
+ "textLineStyle": "textLineStyle",
8521
+ "outerBorderColor": "color",
8522
+ "outerBorderWidth": "border",
8523
+ "outerBorderGap": "size",
8524
+ "outerBorderOutline": "borderStyle",
8525
+ "borderRadius": "radius",
8526
+ "blockFontName": "fontName",
8527
+ "blockFontWeight": "fontWeight",
8528
+ "blockFontSize": "fontSize",
8529
+ "blockLineHeight": "lineHeight",
8530
+ "icon": "icon",
8531
+ "iconTranslateX": "size",
8532
+ "iconTranslateY": "size",
8533
+ "alignSelf": "flexAlign"
8534
+ }
8513
8535
  },
8514
8536
  "required": false,
8515
8537
  "description": ""
@@ -9459,7 +9481,29 @@
9459
9481
  "tokens": {
9460
9482
  "type": {
9461
9483
  "name": "custom",
9462
- "raw": "getTokensPropType('TextArea', 'TextInput')"
9484
+ "raw": {
9485
+ "minLines": "integer",
9486
+ "maxLines": "integer",
9487
+ "backgroundColor": "color",
9488
+ "color": "color",
9489
+ "borderWidth": "border",
9490
+ "borderColor": "color",
9491
+ "borderRadius": "radius",
9492
+ "paddingTop": "size",
9493
+ "paddingBottom": "size",
9494
+ "paddingLeft": "size",
9495
+ "paddingRight": "size",
9496
+ "outerBackgroundColor": "color",
9497
+ "outerBorderWidth": "border",
9498
+ "outerBorderColor": "color",
9499
+ "fontName": "fontName",
9500
+ "fontWeight": "fontWeight",
9501
+ "fontSize": "fontSize",
9502
+ "lineHeight": "lineHeight",
9503
+ "icon": "icon",
9504
+ "iconSize": "size",
9505
+ "iconColor": "color"
9506
+ }
9463
9507
  },
9464
9508
  "required": false,
9465
9509
  "description": ""
@@ -23,13 +23,26 @@ const parseComponentDocs = (name, generated) => {
23
23
 
24
24
  const out = { ...prop }
25
25
 
26
- // check if this prop references the tokens schema
27
- const tokensProp = out.type?.raw?.match(/getTokensPropType\('([A-z]+)'\)/)?.[1]
28
- if (tokensProp) {
29
- if (!schema.components[tokensProp]) {
30
- throw new Error(`Unknown schema component reference: ${tokensProp} from component: ${name}`)
31
- }
32
- out.type = { ...out.type, raw: schema.components[tokensProp] }
26
+ // check if this prop references the tokens schema;
27
+ // this regex extracts unquoted parameter strings from function
28
+ // calls like `getTokensPropType('ChevronLink', 'Link')` with the result
29
+ // being an array: `['ChevronLink', 'Link']`
30
+ const tokensProp = out.type?.raw?.match(/(?<=getTokensPropType\(.*)(\w+)+(?=.*\))/gs)
31
+
32
+ // if so, try and read the schema from the base components
33
+ if (tokensProp && tokensProp.length > 0) {
34
+ let raw = {}
35
+
36
+ tokensProp.forEach((componentName) => {
37
+ if (!schema.components[componentName]) {
38
+ // this would be a run-time error in the base components
39
+ throw new Error(
40
+ `Unknown schema component reference: ${componentName} from component: ${name}`
41
+ )
42
+ }
43
+ raw = { ...raw, ...schema.components[componentName] }
44
+ })
45
+ out.type = { ...out.type, raw }
33
46
  }
34
47
  props[propName] = out
35
48
  })
@@ -15,8 +15,6 @@ var _LinkBase = _interopRequireDefault(require("./LinkBase"));
15
15
 
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
 
18
- var _TextButton$propTypes;
19
-
20
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
19
 
22
20
  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); }
@@ -33,8 +31,6 @@ const TextButton = /*#__PURE__*/(0, _react.forwardRef)(({
33
31
  children,
34
32
  variant,
35
33
  tokens,
36
- // TODO: this may need to use `link` role on Web in the case of being passed both `href` and
37
- // `onPress` in an omniplatform app that uses React Navigation's useLinkProps for internal nav.
38
34
  accessibilityRole = 'button',
39
35
  ...linkProps
40
36
  }, ref) => {
@@ -51,11 +47,6 @@ const TextButton = /*#__PURE__*/(0, _react.forwardRef)(({
51
47
  TextButton.displayName = 'TextButton';
52
48
  TextButton.propTypes = { ..._LinkBase.default.propTypes,
53
49
  onPress: _propTypes.default.func.isRequired
54
- }; // Remove incompatible Link prop (if this build includes propTypes)
55
- // TODO: test if this works with web navigation in omniplatform React Navigation
56
- // https://github.com/telus/universal-design-system/issues/665
57
- // eslint-disable-next-line react/forbid-foreign-prop-types
58
-
59
- if ((_TextButton$propTypes = TextButton.propTypes) !== null && _TextButton$propTypes !== void 0 && _TextButton$propTypes.href) delete TextButton.propTypes.href;
50
+ };
60
51
  var _default = TextButton;
61
52
  exports.default = _default;
@@ -38,20 +38,16 @@ var _default = {
38
38
  select: (0, _getPropSelector.default)(linkPropTypes),
39
39
 
40
40
  /**
41
- * Turn hrefs into press handlers on Native and throw if not given `onPress` or `href`.
41
+ * Turn hrefs into press handlers that open links on Native.
42
42
  *
43
43
  * @param {({ onPress?: () => void, href?: string })}
44
- * @returns {(() => void)|undefined} Returns a press handler, or undefined on web if href
45
- * string is provided. Expects calling component to use href string on web (e.g. in `<a>`).
44
+ * @returns {(() => void)|undefined} Returns a press handler, or undefined on web if no press
45
+ * handler is provided (expects calling component to render as `<a href={href}>` on web).
46
46
  */
47
47
  handleHref: ({
48
48
  onPress,
49
49
  href
50
50
  }) => {
51
- if (!href && !onPress) {
52
- throw new Error('handleHref requires either href or onPress');
53
- }
54
-
55
51
  return _Platform.default.select({
56
52
  web: onPress,
57
53
  default: (...args) => {
@@ -1,5 +1,3 @@
1
- var _TextButton$propTypes;
2
-
3
1
  import React, { forwardRef } from 'react';
4
2
  import PropTypes from 'prop-types';
5
3
  import { useThemeTokensCallback } from '../ThemeProvider';
@@ -16,8 +14,6 @@ const TextButton = /*#__PURE__*/forwardRef(({
16
14
  children,
17
15
  variant,
18
16
  tokens,
19
- // TODO: this may need to use `link` role on Web in the case of being passed both `href` and
20
- // `onPress` in an omniplatform app that uses React Navigation's useLinkProps for internal nav.
21
17
  accessibilityRole = 'button',
22
18
  ...linkProps
23
19
  }, ref) => {
@@ -34,10 +30,5 @@ const TextButton = /*#__PURE__*/forwardRef(({
34
30
  TextButton.displayName = 'TextButton';
35
31
  TextButton.propTypes = { ...LinkBase.propTypes,
36
32
  onPress: PropTypes.func.isRequired
37
- }; // Remove incompatible Link prop (if this build includes propTypes)
38
- // TODO: test if this works with web navigation in omniplatform React Navigation
39
- // https://github.com/telus/universal-design-system/issues/665
40
- // eslint-disable-next-line react/forbid-foreign-prop-types
41
-
42
- if ((_TextButton$propTypes = TextButton.propTypes) !== null && _TextButton$propTypes !== void 0 && _TextButton$propTypes.href) delete TextButton.propTypes.href;
33
+ };
43
34
  export default TextButton;
@@ -22,20 +22,16 @@ export default {
22
22
  select: getPropSelector(linkPropTypes),
23
23
 
24
24
  /**
25
- * Turn hrefs into press handlers on Native and throw if not given `onPress` or `href`.
25
+ * Turn hrefs into press handlers that open links on Native.
26
26
  *
27
27
  * @param {({ onPress?: () => void, href?: string })}
28
- * @returns {(() => void)|undefined} Returns a press handler, or undefined on web if href
29
- * string is provided. Expects calling component to use href string on web (e.g. in `<a>`).
28
+ * @returns {(() => void)|undefined} Returns a press handler, or undefined on web if no press
29
+ * handler is provided (expects calling component to render as `<a href={href}>` on web).
30
30
  */
31
31
  handleHref: ({
32
32
  onPress,
33
33
  href
34
34
  }) => {
35
- if (!href && !onPress) {
36
- throw new Error('handleHref requires either href or onPress');
37
- }
38
-
39
35
  return Platform.select({
40
36
  web: onPress,
41
37
  default: (...args) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telus-uds/components-base",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Base components",
5
5
  "keywords": [
6
6
  "base"
@@ -10,19 +10,7 @@ import LinkBase from './LinkBase'
10
10
  * take place on the current page, or for navigation within an app.
11
11
  */
12
12
  const TextButton = forwardRef(
13
- (
14
- {
15
- onPress,
16
- children,
17
- variant,
18
- tokens,
19
- // TODO: this may need to use `link` role on Web in the case of being passed both `href` and
20
- // `onPress` in an omniplatform app that uses React Navigation's useLinkProps for internal nav.
21
- accessibilityRole = 'button',
22
- ...linkProps
23
- },
24
- ref
25
- ) => {
13
+ ({ onPress, children, variant, tokens, accessibilityRole = 'button', ...linkProps }, ref) => {
26
14
  const getTokens = useThemeTokensCallback('Link', tokens, variant)
27
15
  return (
28
16
  <LinkBase
@@ -44,10 +32,4 @@ TextButton.propTypes = {
44
32
  onPress: PropTypes.func.isRequired
45
33
  }
46
34
 
47
- // Remove incompatible Link prop (if this build includes propTypes)
48
- // TODO: test if this works with web navigation in omniplatform React Navigation
49
- // https://github.com/telus/universal-design-system/issues/665
50
- // eslint-disable-next-line react/forbid-foreign-prop-types
51
- if (TextButton.propTypes?.href) delete TextButton.propTypes.href
52
-
53
35
  export default TextButton
@@ -22,16 +22,13 @@ export default {
22
22
  */
23
23
  select: getPropSelector(linkPropTypes),
24
24
  /**
25
- * Turn hrefs into press handlers on Native and throw if not given `onPress` or `href`.
25
+ * Turn hrefs into press handlers that open links on Native.
26
26
  *
27
27
  * @param {({ onPress?: () => void, href?: string })}
28
- * @returns {(() => void)|undefined} Returns a press handler, or undefined on web if href
29
- * string is provided. Expects calling component to use href string on web (e.g. in `<a>`).
28
+ * @returns {(() => void)|undefined} Returns a press handler, or undefined on web if no press
29
+ * handler is provided (expects calling component to render as `<a href={href}>` on web).
30
30
  */
31
31
  handleHref: ({ onPress, href }) => {
32
- if (!href && !onPress) {
33
- throw new Error('handleHref requires either href or onPress')
34
- }
35
32
  return Platform.select({
36
33
  web: onPress,
37
34
  default: (...args) => {
@@ -1,22 +0,0 @@
1
- /* eslint-disable no-console */
2
- import React from 'react'
3
- import { render } from '@testing-library/react-native'
4
-
5
- import Theme from '../../__fixtures__/Theme'
6
- import LinkBase from '../../src/Link/LinkBase'
7
-
8
- beforeEach(() => jest.clearAllMocks())
9
-
10
- describe('LinkBase', () => {
11
- it('throws if neither href nor onPress are provided', async () => {
12
- jest.spyOn(console, 'error').mockImplementation()
13
- expect(() =>
14
- render(
15
- <Theme>
16
- <LinkBase>click me</LinkBase>
17
- </Theme>
18
- )
19
- ).toThrow()
20
- expect(console.error).toHaveBeenCalledTimes(1)
21
- })
22
- })