@telus-uds/components-web 2.31.5 → 2.32.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,25 @@
1
1
  # Change Log - @telus-uds/components-web
2
2
 
3
- This log was last generated on Wed, 06 Mar 2024 00:02:37 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 12 Mar 2024 22:22:38 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.32.0
8
+
9
+ Tue, 12 Mar 2024 22:22:38 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Changes to enable the new variants for Footnote.Link (35577399+JoshHC@users.noreply.github.com)
14
+ - Bump @telus-uds/components-base to v1.80.0
15
+
16
+ ### Patches
17
+
18
+ - Make `WebPortal` SSR compliant and use it in `DatePicker` instead of `Portal` from `@gorhom/portal` (shahzaibkhalidmalik@outlook.com)
19
+
7
20
  ## 2.31.5
8
21
 
9
- Wed, 06 Mar 2024 00:02:37 GMT
22
+ Wed, 06 Mar 2024 00:09:16 GMT
10
23
 
11
24
  ### Patches
12
25
 
@@ -17,6 +17,7 @@ var _lodash = require("lodash");
17
17
  var _CalendarContainer = _interopRequireDefault(require("./CalendarContainer"));
18
18
  var _dictionary = _interopRequireDefault(require("./dictionary"));
19
19
  var _utils = require("../utils");
20
+ var _WebPortal = _interopRequireDefault(require("../WebPortal"));
20
21
  var _jsxRuntime = require("react/jsx-runtime");
21
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
23
  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); }
@@ -125,7 +126,7 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
125
126
  });
126
127
  (0, _componentsBase.useSafeLayoutEffect)(() => {
127
128
  const updateDimensions = () => {
128
- if (inline) return;
129
+ if (inline || !textInputRef.current) return;
129
130
  const {
130
131
  left,
131
132
  top
@@ -138,7 +139,7 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
138
139
  const throttledUpdateDimensions = (0, _lodash.throttle)(updateDimensions, 100, {
139
140
  leading: false
140
141
  });
141
- updateDimensions();
142
+ throttledUpdateDimensions();
142
143
  window.addEventListener('resize', throttledUpdateDimensions);
143
144
  return () => window.removeEventListener('resize', throttledUpdateDimensions);
144
145
  }, []);
@@ -328,7 +329,7 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
328
329
  validation: validation,
329
330
  inactive: disabled,
330
331
  ref: textInputRef,
331
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Portal, {
332
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_WebPortal.default, {
332
333
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PortalPositionedContainer, {
333
334
  top: datePickerPosition.top,
334
335
  left: datePickerPosition.left,
@@ -30,7 +30,7 @@ const StyledSup = /*#__PURE__*/_styledComponents.default.sup.withConfig({
30
30
  cursor: 'pointer',
31
31
  // we want to fallback on 'smaller' but have a valid size when a custom font size is provided.
32
32
  fontSize: fontSize ? `${fontSize}px` : 'smaller',
33
- lineHeight: `${fontSize * lineHeight}px`,
33
+ lineHeight: lineHeight ?? `${fontSize * 2}px`,
34
34
  margin: 0,
35
35
  paddingVertical: 0,
36
36
  paddingLeft,
@@ -90,7 +90,7 @@ const FootnoteLink = _ref2 => {
90
90
  tabIndex: 0,
91
91
  ...selectProps(rest),
92
92
  ...themeTokens,
93
- fontSize: fontSize,
93
+ fontSize: fontSize ?? themeTokens.fontSize,
94
94
  children: `${num}${index !== numbers.length - 1 ? ',' : ''}`
95
95
  }, num))
96
96
  });
@@ -100,6 +100,7 @@ const copyShape = _propTypes.default.shape({
100
100
  });
101
101
  FootnoteLink.propTypes = {
102
102
  ...selectedSystemPropTypes,
103
+ variant: _componentsBase.variantProp.propType,
103
104
  /**
104
105
  * Use the `copy` prop to either select provided English or French copy by passing 'en' or 'fr' respectively.
105
106
  * To provide your own, pass a JSON object with the key `a11yLabel`.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
8
  var _reactDom = _interopRequireDefault(require("react-dom"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
11
  /**
11
12
  * WebPortal component renders its children in a separate portal container appended to the document body.
@@ -29,14 +30,22 @@ const WebPortal = _ref => {
29
30
  let {
30
31
  children
31
32
  } = _ref;
32
- const portalContainer = document.createElement('div');
33
+ const [portalContainer, setPortalContainer] = (0, _react.useState)(null);
33
34
  (0, _react.useEffect)(() => {
34
- document.body.appendChild(portalContainer);
35
+ const container = document.createElement('div');
36
+ document.body.appendChild(container);
37
+ setPortalContainer(container);
35
38
  return () => {
36
- document.body.removeChild(portalContainer);
39
+ if (container && container.parentNode) {
40
+ container.parentNode.removeChild(container);
41
+ }
37
42
  };
38
- }, [portalContainer]);
43
+ }, []);
44
+ if (!portalContainer) return null;
39
45
  return /*#__PURE__*/_reactDom.default.createPortal(children, portalContainer);
40
46
  };
47
+ WebPortal.propTypes = {
48
+ children: _propTypes.default.node.isRequired
49
+ };
41
50
  var _default = WebPortal;
42
51
  exports.default = _default;
@@ -5,12 +5,13 @@ import momentPropTypes from 'react-moment-proptypes';
5
5
  import 'react-dates/initialize';
6
6
  import SingleDatePicker from 'react-dates/lib/components/SingleDatePicker';
7
7
  import DayPickerSingleDateController from 'react-dates/lib/components/DayPickerSingleDateController';
8
- import { IconButton, TextInput, selectSystemProps, useCopy, useViewport, useThemeTokens, applyTextStyles, getTokensPropType, Portal, useSafeLayoutEffect } from '@telus-uds/components-base';
8
+ import { IconButton, TextInput, selectSystemProps, useCopy, useViewport, useThemeTokens, applyTextStyles, getTokensPropType, useSafeLayoutEffect } from '@telus-uds/components-base';
9
9
  import moment from 'moment';
10
10
  import { isUndefined, throttle } from 'lodash';
11
11
  import CalendarContainer from './CalendarContainer';
12
12
  import dictionary from './dictionary';
13
13
  import { htmlAttrs } from '../utils';
14
+ import WebPortal from '../WebPortal';
14
15
  import { jsx as _jsx } from "react/jsx-runtime";
15
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
17
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -118,7 +119,7 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref3, ref) => {
118
119
  });
119
120
  useSafeLayoutEffect(() => {
120
121
  const updateDimensions = () => {
121
- if (inline) return;
122
+ if (inline || !textInputRef.current) return;
122
123
  const {
123
124
  left,
124
125
  top
@@ -131,7 +132,7 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref3, ref) => {
131
132
  const throttledUpdateDimensions = throttle(updateDimensions, 100, {
132
133
  leading: false
133
134
  });
134
- updateDimensions();
135
+ throttledUpdateDimensions();
135
136
  window.addEventListener('resize', throttledUpdateDimensions);
136
137
  return () => window.removeEventListener('resize', throttledUpdateDimensions);
137
138
  }, []);
@@ -321,7 +322,7 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref3, ref) => {
321
322
  validation: validation,
322
323
  inactive: disabled,
323
324
  ref: textInputRef,
324
- children: /*#__PURE__*/_jsx(Portal, {
325
+ children: /*#__PURE__*/_jsx(WebPortal, {
325
326
  children: /*#__PURE__*/_jsx(PortalPositionedContainer, {
326
327
  top: datePickerPosition.top,
327
328
  left: datePickerPosition.left,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
- import { applyTextStyles, selectSystemProps, useCopy, useThemeTokens } from '@telus-uds/components-base';
4
+ import { applyTextStyles, selectSystemProps, useCopy, useThemeTokens, variantProp } from '@telus-uds/components-base';
5
5
  import dictionary from './dictionary';
6
6
  import { htmlAttrs } from '../utils';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -24,7 +24,7 @@ const StyledSup = /*#__PURE__*/styled.sup.withConfig({
24
24
  cursor: 'pointer',
25
25
  // we want to fallback on 'smaller' but have a valid size when a custom font size is provided.
26
26
  fontSize: fontSize ? `${fontSize}px` : 'smaller',
27
- lineHeight: `${fontSize * lineHeight}px`,
27
+ lineHeight: lineHeight ?? `${fontSize * 2}px`,
28
28
  margin: 0,
29
29
  paddingVertical: 0,
30
30
  paddingLeft,
@@ -84,7 +84,7 @@ const FootnoteLink = _ref2 => {
84
84
  tabIndex: 0,
85
85
  ...selectProps(rest),
86
86
  ...themeTokens,
87
- fontSize: fontSize,
87
+ fontSize: fontSize ?? themeTokens.fontSize,
88
88
  children: `${num}${index !== numbers.length - 1 ? ',' : ''}`
89
89
  }, num))
90
90
  });
@@ -94,6 +94,7 @@ const copyShape = PropTypes.shape({
94
94
  });
95
95
  FootnoteLink.propTypes = {
96
96
  ...selectedSystemPropTypes,
97
+ variant: variantProp.propType,
97
98
  /**
98
99
  * Use the `copy` prop to either select provided English or French copy by passing 'en' or 'fr' respectively.
99
100
  * To provide your own, pass a JSON object with the key `a11yLabel`.
@@ -1,5 +1,6 @@
1
- import { useEffect } from 'react';
1
+ import { useState, useEffect } from 'react';
2
2
  import ReactDOM from 'react-dom';
3
+ import PropTypes from 'prop-types';
3
4
 
4
5
  /**
5
6
  * WebPortal component renders its children in a separate portal container appended to the document body.
@@ -23,13 +24,21 @@ const WebPortal = _ref => {
23
24
  let {
24
25
  children
25
26
  } = _ref;
26
- const portalContainer = document.createElement('div');
27
+ const [portalContainer, setPortalContainer] = useState(null);
27
28
  useEffect(() => {
28
- document.body.appendChild(portalContainer);
29
+ const container = document.createElement('div');
30
+ document.body.appendChild(container);
31
+ setPortalContainer(container);
29
32
  return () => {
30
- document.body.removeChild(portalContainer);
33
+ if (container && container.parentNode) {
34
+ container.parentNode.removeChild(container);
35
+ }
31
36
  };
32
- }, [portalContainer]);
37
+ }, []);
38
+ if (!portalContainer) return null;
33
39
  return /*#__PURE__*/ReactDOM.createPortal(children, portalContainer);
34
40
  };
41
+ WebPortal.propTypes = {
42
+ children: PropTypes.node.isRequired
43
+ };
35
44
  export default WebPortal;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  ],
6
6
  "dependencies": {
7
7
  "@gorhom/portal": "^1.0.14",
8
- "@telus-uds/components-base": "1.79.0",
8
+ "@telus-uds/components-base": "1.80.0",
9
9
  "@telus-uds/system-constants": "^1.3.0",
10
10
  "fscreen": "^1.2.0",
11
11
  "lodash.omit": "^4.5.0",
@@ -83,5 +83,5 @@
83
83
  "skip": true
84
84
  },
85
85
  "types": "types/index.d.ts",
86
- "version": "2.31.5"
86
+ "version": "2.32.0"
87
87
  }
@@ -14,7 +14,6 @@ import {
14
14
  useThemeTokens,
15
15
  applyTextStyles,
16
16
  getTokensPropType,
17
- Portal,
18
17
  useSafeLayoutEffect
19
18
  } from '@telus-uds/components-base'
20
19
  import moment from 'moment'
@@ -22,6 +21,7 @@ import { isUndefined, throttle } from 'lodash'
22
21
  import CalendarContainer from './CalendarContainer'
23
22
  import dictionary from './dictionary'
24
23
  import { htmlAttrs } from '../utils'
24
+ import WebPortal from '../WebPortal'
25
25
 
26
26
  const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs])
27
27
  const dateFormat = 'DD / MM / YYYY'
@@ -110,7 +110,7 @@ const DatePicker = forwardRef(
110
110
 
111
111
  useSafeLayoutEffect(() => {
112
112
  const updateDimensions = () => {
113
- if (inline) return
113
+ if (inline || !textInputRef.current) return
114
114
  const { left, top } = textInputRef.current.getBoundingClientRect()
115
115
  setDatePickerPosition({
116
116
  left,
@@ -118,7 +118,7 @@ const DatePicker = forwardRef(
118
118
  })
119
119
  }
120
120
  const throttledUpdateDimensions = throttle(updateDimensions, 100, { leading: false })
121
- updateDimensions()
121
+ throttledUpdateDimensions()
122
122
  window.addEventListener('resize', throttledUpdateDimensions)
123
123
  return () => window.removeEventListener('resize', throttledUpdateDimensions)
124
124
  }, [])
@@ -294,7 +294,7 @@ const DatePicker = forwardRef(
294
294
  inactive={disabled}
295
295
  ref={textInputRef}
296
296
  >
297
- <Portal>
297
+ <WebPortal>
298
298
  {/* Because `SingleDatePicker` is an absolutely positioned element,
299
299
  * putting it in a `Portal` breaks view heirarchy because it doesn't
300
300
  * align with `TextInput`, but rather position itself with the nearest
@@ -359,7 +359,7 @@ const DatePicker = forwardRef(
359
359
  />
360
360
  </CalendarContainer>
361
361
  </PortalPositionedContainer>
362
- </Portal>
362
+ </WebPortal>
363
363
  </TextInput>
364
364
  </DateInputWrapper>
365
365
  )}
@@ -5,7 +5,8 @@ import {
5
5
  applyTextStyles,
6
6
  selectSystemProps,
7
7
  useCopy,
8
- useThemeTokens
8
+ useThemeTokens,
9
+ variantProp
9
10
  } from '@telus-uds/components-base'
10
11
  import dictionary from './dictionary'
11
12
  import { htmlAttrs } from '../utils'
@@ -20,7 +21,7 @@ const StyledSup = styled.sup(
20
21
  cursor: 'pointer',
21
22
  // we want to fallback on 'smaller' but have a valid size when a custom font size is provided.
22
23
  fontSize: fontSize ? `${fontSize}px` : 'smaller',
23
- lineHeight: `${fontSize * lineHeight}px`,
24
+ lineHeight: lineHeight ?? `${fontSize * 2}px`,
24
25
  margin: 0,
25
26
  paddingVertical: 0,
26
27
  paddingLeft,
@@ -83,7 +84,7 @@ const FootnoteLink = ({
83
84
  tabIndex={0}
84
85
  {...selectProps(rest)}
85
86
  {...themeTokens}
86
- fontSize={fontSize}
87
+ fontSize={fontSize ?? themeTokens.fontSize}
87
88
  >
88
89
  {`${num}${index !== numbers.length - 1 ? ',' : ''}`}
89
90
  </StyledSup>
@@ -98,6 +99,7 @@ const copyShape = PropTypes.shape({
98
99
 
99
100
  FootnoteLink.propTypes = {
100
101
  ...selectedSystemPropTypes,
102
+ variant: variantProp.propType,
101
103
  /**
102
104
  * Use the `copy` prop to either select provided English or French copy by passing 'en' or 'fr' respectively.
103
105
  * To provide your own, pass a JSON object with the key `a11yLabel`.
@@ -1,5 +1,6 @@
1
- import { useEffect } from 'react'
1
+ import { useState, useEffect } from 'react'
2
2
  import ReactDOM from 'react-dom'
3
+ import PropTypes from 'prop-types'
3
4
 
4
5
  /**
5
6
  * WebPortal component renders its children in a separate portal container appended to the document body.
@@ -20,17 +21,27 @@ import ReactDOM from 'react-dom'
20
21
  */
21
22
 
22
23
  const WebPortal = ({ children }) => {
23
- const portalContainer = document.createElement('div')
24
+ const [portalContainer, setPortalContainer] = useState(null)
24
25
 
25
26
  useEffect(() => {
26
- document.body.appendChild(portalContainer)
27
+ const container = document.createElement('div')
28
+ document.body.appendChild(container)
29
+ setPortalContainer(container)
27
30
 
28
31
  return () => {
29
- document.body.removeChild(portalContainer)
32
+ if (container && container.parentNode) {
33
+ container.parentNode.removeChild(container)
34
+ }
30
35
  }
31
- }, [portalContainer])
36
+ }, [])
37
+
38
+ if (!portalContainer) return null
32
39
 
33
40
  return ReactDOM.createPortal(children, portalContainer)
34
41
  }
35
42
 
43
+ WebPortal.propTypes = {
44
+ children: PropTypes.node.isRequired
45
+ }
46
+
36
47
  export default WebPortal