@telus-uds/components-web 2.31.5 → 2.32.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.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,35 @@
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, 19 Mar 2024 18:37:02 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 2.32.1
8
+
9
+ Tue, 19 Mar 2024 18:37:02 GMT
10
+
11
+ ### Patches
12
+
13
+ - `Autocomplete`: Overlay does not render next to `TextInput` (shahzaibkhalidmalik@outlook.com)
14
+ - `NavigationBar`: overlay may render on top of toggle button in smaller viewports (shahzaibkhalidmalik@outlook.com)
15
+ - Bump @telus-uds/components-base to v1.80.1
16
+
17
+ ## 2.32.0
18
+
19
+ Tue, 12 Mar 2024 22:26:51 GMT
20
+
21
+ ### Minor changes
22
+
23
+ - Changes to enable the new variants for Footnote.Link (35577399+JoshHC@users.noreply.github.com)
24
+ - Bump @telus-uds/components-base to v1.80.0
25
+
26
+ ### Patches
27
+
28
+ - Make `WebPortal` SSR compliant and use it in `DatePicker` instead of `Portal` from `@gorhom/portal` (shahzaibkhalidmalik@outlook.com)
29
+
7
30
  ## 2.31.5
8
31
 
9
- Wed, 06 Mar 2024 00:02:37 GMT
32
+ Wed, 06 Mar 2024 00:09:16 GMT
10
33
 
11
34
  ### Patches
12
35
 
@@ -125,7 +125,7 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
125
125
  });
126
126
  (0, _componentsBase.useSafeLayoutEffect)(() => {
127
127
  const updateDimensions = () => {
128
- if (inline) return;
128
+ if (inline || !textInputRef.current) return;
129
129
  const {
130
130
  left,
131
131
  top
@@ -138,7 +138,7 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
138
138
  const throttledUpdateDimensions = (0, _lodash.throttle)(updateDimensions, 100, {
139
139
  leading: false
140
140
  });
141
- updateDimensions();
141
+ throttledUpdateDimensions();
142
142
  window.addEventListener('resize', throttledUpdateDimensions);
143
143
  return () => window.removeEventListener('resize', throttledUpdateDimensions);
144
144
  }, []);
@@ -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`.
@@ -33,33 +33,38 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
33
33
  } = _ref;
34
34
  const focusTrapRef = (0, _react.useRef)();
35
35
  const maxWidth = 289; // Slightly over 288 of nav item to account for subpixel rounding
36
+ const defaultOffsets = {
37
+ offsets: {
38
+ vertical: 4
39
+ }
40
+ };
36
41
  const {
37
42
  align,
38
43
  offsets,
39
44
  minWidth
40
45
  } = (0, _componentsBase.useResponsiveProp)({
41
46
  xs: {
47
+ ...defaultOffsets,
42
48
  align: {
43
- top: 'top',
49
+ top: 'bottom',
44
50
  left: 'left'
45
51
  },
46
52
  minWidth: maxWidth
47
53
  },
48
54
  sm: {
55
+ ...defaultOffsets,
49
56
  align: {
50
- top: 'top',
57
+ top: 'bottom',
51
58
  right: 'right'
52
59
  },
53
60
  minWidth: maxWidth
54
61
  },
55
62
  lg: {
63
+ ...defaultOffsets,
56
64
  align: {
57
65
  top: 'bottom',
58
66
  center: 'center'
59
67
  },
60
- offsets: {
61
- vertical: 4
62
- },
63
68
  minWidth: 192
64
69
  }
65
70
  });
@@ -177,6 +177,12 @@ Object.defineProperty(exports, "Pagination", {
177
177
  return _componentsBase.Pagination;
178
178
  }
179
179
  });
180
+ Object.defineProperty(exports, "Portal", {
181
+ enumerable: true,
182
+ get: function () {
183
+ return _componentsBase.Portal;
184
+ }
185
+ });
180
186
  Object.defineProperty(exports, "QuickLinks", {
181
187
  enumerable: true,
182
188
  get: function () {
@@ -357,6 +363,12 @@ Object.defineProperty(exports, "ViewportProvider", {
357
363
  return _componentsBase.ViewportProvider;
358
364
  }
359
365
  });
366
+ Object.defineProperty(exports, "WebPortal", {
367
+ enumerable: true,
368
+ get: function () {
369
+ return _componentsBase.Portal;
370
+ }
371
+ });
360
372
  Object.defineProperty(exports, "useCarousel", {
361
373
  enumerable: true,
362
374
  get: function () {
package/lib/index.js CHANGED
@@ -42,8 +42,7 @@ var _exportNames = {
42
42
  TermsAndConditions: true,
43
43
  NavigationBar: true,
44
44
  Progress: true,
45
- SkeletonProvider: true,
46
- WebPortal: true
45
+ SkeletonProvider: true
47
46
  };
48
47
  Object.defineProperty(exports, "Badge", {
49
48
  enumerable: true,
@@ -255,12 +254,6 @@ Object.defineProperty(exports, "WaffleGrid", {
255
254
  return _WaffleGrid.default;
256
255
  }
257
256
  });
258
- Object.defineProperty(exports, "WebPortal", {
259
- enumerable: true,
260
- get: function () {
261
- return _WebPortal.default;
262
- }
263
- });
264
257
  Object.defineProperty(exports, "WebVideo", {
265
258
  enumerable: true,
266
259
  get: function () {
@@ -315,7 +308,6 @@ var _TermsAndConditions = _interopRequireDefault(require("./TermsAndConditions")
315
308
  var _NavigationBar = _interopRequireDefault(require("./NavigationBar"));
316
309
  var _Progress = _interopRequireDefault(require("./Progress"));
317
310
  var _SkeletonProvider = _interopRequireDefault(require("./SkeletonProvider"));
318
- var _WebPortal = _interopRequireDefault(require("./WebPortal"));
319
311
  var _baseExports = require("./baseExports");
320
312
  Object.keys(_baseExports).forEach(function (key) {
321
313
  if (key === "default" || key === "__esModule") return;
@@ -5,7 +5,7 @@ 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, Portal, 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';
@@ -118,7 +118,7 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref3, ref) => {
118
118
  });
119
119
  useSafeLayoutEffect(() => {
120
120
  const updateDimensions = () => {
121
- if (inline) return;
121
+ if (inline || !textInputRef.current) return;
122
122
  const {
123
123
  left,
124
124
  top
@@ -131,7 +131,7 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref3, ref) => {
131
131
  const throttledUpdateDimensions = throttle(updateDimensions, 100, {
132
132
  leading: false
133
133
  });
134
- updateDimensions();
134
+ throttledUpdateDimensions();
135
135
  window.addEventListener('resize', throttledUpdateDimensions);
136
136
  return () => window.removeEventListener('resize', throttledUpdateDimensions);
137
137
  }, []);
@@ -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`.
@@ -28,33 +28,38 @@ const NavigationSubMenu = _ref => {
28
28
  } = _ref;
29
29
  const focusTrapRef = useRef();
30
30
  const maxWidth = 289; // Slightly over 288 of nav item to account for subpixel rounding
31
+ const defaultOffsets = {
32
+ offsets: {
33
+ vertical: 4
34
+ }
35
+ };
31
36
  const {
32
37
  align,
33
38
  offsets,
34
39
  minWidth
35
40
  } = useResponsiveProp({
36
41
  xs: {
42
+ ...defaultOffsets,
37
43
  align: {
38
- top: 'top',
44
+ top: 'bottom',
39
45
  left: 'left'
40
46
  },
41
47
  minWidth: maxWidth
42
48
  },
43
49
  sm: {
50
+ ...defaultOffsets,
44
51
  align: {
45
- top: 'top',
52
+ top: 'bottom',
46
53
  right: 'right'
47
54
  },
48
55
  minWidth: maxWidth
49
56
  },
50
57
  lg: {
58
+ ...defaultOffsets,
51
59
  align: {
52
60
  top: 'bottom',
53
61
  center: 'center'
54
62
  },
55
- offsets: {
56
- vertical: 4
57
- },
58
63
  minWidth: 192
59
64
  }
60
65
  });
@@ -5,7 +5,7 @@ export {
5
5
  /**
6
6
  * Most base components should be re-exported as-is.
7
7
  */
8
- A11yText, ActivityIndicator, Autocomplete, Box, Button, BaseProvider, A11yInfoProvider, ViewportProvider, ThemeProvider, ButtonDropdown, ButtonGroup, ButtonLink, Carousel, CarouselTabs, Checkbox, CheckboxGroup, ChevronLink, ColourToggle, Divider, ExpandCollapse, Feedback, FlexGrid, Icon, InputLabel, InputSupports, Link, Listbox, Modal, MultiSelectFilter, Notification, Pagination, QuickLinks, QuickLinksFeature, Radio, RadioGroup, RadioCard, RadioCardGroup, Responsive, Search, Select, SideNav, Skeleton, SkipLink, Spacer, StackView, StackWrap, StepTracker, Tabs, Tags, TextButton, TextArea, TextInput, Timeline, ToggleSwitch, ToggleSwitchGroup, TooltipButton, Tooltip, Typography, Validator,
8
+ A11yText, ActivityIndicator, Autocomplete, Box, Button, BaseProvider, A11yInfoProvider, ViewportProvider, ThemeProvider, ButtonDropdown, ButtonGroup, ButtonLink, Carousel, CarouselTabs, Checkbox, CheckboxGroup, ChevronLink, ColourToggle, Divider, ExpandCollapse, Feedback, FlexGrid, Icon, InputLabel, InputSupports, Link, Listbox, Modal, MultiSelectFilter, Notification, Pagination, Portal, QuickLinks, QuickLinksFeature, Radio, RadioGroup, RadioCard, RadioCardGroup, Responsive, Search, Select, SideNav, Skeleton, SkipLink, Spacer, StackView, StackWrap, StepTracker, Tabs, Tags, TextButton, TextArea, TextInput, Timeline, ToggleSwitch, ToggleSwitchGroup, TooltipButton, Tooltip, Typography, Validator,
9
9
  /*
10
10
  * Most utilities exported from @telus-uds/components-base are for building systems, not apps.
11
11
  * Re-export only those utilities with a stable API and known use cases within apps / pages.
@@ -13,4 +13,7 @@ A11yText, ActivityIndicator, Autocomplete, Box, Button, BaseProvider, A11yInfoPr
13
13
  // Enable access to the viewports system for app-specific responsive layouts and features
14
14
  useResponsiveProp, useViewport,
15
15
  // TODO reenable ViewportContext once published from base // enable localised viewport overrides e.g. in tests, narrow columns, etc
16
- useCarousel, useSetTheme } from '@telus-uds/components-base';
16
+ useCarousel, useSetTheme } from '@telus-uds/components-base';
17
+
18
+ // TODO: Added `WebPortal` alias for backwards compatibility with `Portal` from `@telus-uds/components-base`. Remove in next major version.
19
+ export { Portal as WebPortal } from '@telus-uds/components-base';
@@ -36,6 +36,5 @@ export { default as TermsAndConditions } from './TermsAndConditions';
36
36
  export { default as NavigationBar } from './NavigationBar';
37
37
  export { default as Progress } from './Progress';
38
38
  export { default as SkeletonProvider } from './SkeletonProvider';
39
- export { default as WebPortal } from './WebPortal';
40
39
  export { ssrStyles } from './utils';
41
40
  export * from './baseExports';
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.1",
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.1"
87
87
  }
@@ -8,13 +8,13 @@ import DayPickerSingleDateController from 'react-dates/lib/components/DayPickerS
8
8
  import {
9
9
  IconButton,
10
10
  TextInput,
11
+ Portal,
11
12
  selectSystemProps,
12
13
  useCopy,
13
14
  useViewport,
14
15
  useThemeTokens,
15
16
  applyTextStyles,
16
17
  getTokensPropType,
17
- Portal,
18
18
  useSafeLayoutEffect
19
19
  } from '@telus-uds/components-base'
20
20
  import moment from 'moment'
@@ -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
  }, [])
@@ -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`.
@@ -25,12 +25,13 @@ const NavigationSubMenu = ({
25
25
  const focusTrapRef = useRef()
26
26
 
27
27
  const maxWidth = 289 // Slightly over 288 of nav item to account for subpixel rounding
28
+ const defaultOffsets = { offsets: { vertical: 4 } }
28
29
  const { align, offsets, minWidth } = useResponsiveProp({
29
- xs: { align: { top: 'top', left: 'left' }, minWidth: maxWidth },
30
- sm: { align: { top: 'top', right: 'right' }, minWidth: maxWidth },
30
+ xs: { ...defaultOffsets, align: { top: 'bottom', left: 'left' }, minWidth: maxWidth },
31
+ sm: { ...defaultOffsets, align: { top: 'bottom', right: 'right' }, minWidth: maxWidth },
31
32
  lg: {
33
+ ...defaultOffsets,
32
34
  align: { top: 'bottom', center: 'center' },
33
- offsets: { vertical: 4 },
34
35
  minWidth: 192
35
36
  }
36
37
  })
@@ -36,6 +36,7 @@ export {
36
36
  MultiSelectFilter,
37
37
  Notification,
38
38
  Pagination,
39
+ Portal,
39
40
  QuickLinks,
40
41
  QuickLinksFeature,
41
42
  Radio,
@@ -74,3 +75,6 @@ export {
74
75
  useCarousel,
75
76
  useSetTheme
76
77
  } from '@telus-uds/components-base'
78
+
79
+ // TODO: Added `WebPortal` alias for backwards compatibility with `Portal` from `@telus-uds/components-base`. Remove in next major version.
80
+ export { Portal as WebPortal } from '@telus-uds/components-base'
package/src/index.js CHANGED
@@ -36,7 +36,6 @@ export { default as TermsAndConditions } from './TermsAndConditions'
36
36
  export { default as NavigationBar } from './NavigationBar'
37
37
  export { default as Progress } from './Progress'
38
38
  export { default as SkeletonProvider } from './SkeletonProvider'
39
- export { default as WebPortal } from './WebPortal'
40
39
 
41
40
  export { ssrStyles } from './utils'
42
41
 
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = require("react");
8
- var _reactDom = _interopRequireDefault(require("react-dom"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- /**
11
- * WebPortal component renders its children in a separate portal container appended to the document body.
12
- *
13
- * While `@gorhom/portal` works well for a lot of use-cases, there are some issues with it, particularly around
14
- * reading context values (see issues below). For web-only components, it is safe to replace `Portal` from `@gorhom/portal`
15
- * to `WebPortal` to solve such issues
16
- *
17
- * https://github.com/gorhom/react-native-portal/issues/34
18
- * https://github.com/gorhom/react-native-portal/issues/2
19
- * https://github.com/gorhom/react-native-portal/issues/3
20
- * https://github.com/gorhom/react-native-portal/issues/31
21
- *
22
- * @component
23
- * @param {object} props - The component props.
24
- * @param {React.ReactNode} props.children - The content to render within the portal.
25
- * @returns {React.ReactPortal} The React portal component.
26
- */
27
-
28
- const WebPortal = _ref => {
29
- let {
30
- children
31
- } = _ref;
32
- const portalContainer = document.createElement('div');
33
- (0, _react.useEffect)(() => {
34
- document.body.appendChild(portalContainer);
35
- return () => {
36
- document.body.removeChild(portalContainer);
37
- };
38
- }, [portalContainer]);
39
- return /*#__PURE__*/_reactDom.default.createPortal(children, portalContainer);
40
- };
41
- var _default = WebPortal;
42
- exports.default = _default;
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _WebPortal = _interopRequireDefault(require("./WebPortal"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- var _default = _WebPortal.default;
10
- exports.default = _default;
@@ -1,35 +0,0 @@
1
- import { useEffect } from 'react';
2
- import ReactDOM from 'react-dom';
3
-
4
- /**
5
- * WebPortal component renders its children in a separate portal container appended to the document body.
6
- *
7
- * While `@gorhom/portal` works well for a lot of use-cases, there are some issues with it, particularly around
8
- * reading context values (see issues below). For web-only components, it is safe to replace `Portal` from `@gorhom/portal`
9
- * to `WebPortal` to solve such issues
10
- *
11
- * https://github.com/gorhom/react-native-portal/issues/34
12
- * https://github.com/gorhom/react-native-portal/issues/2
13
- * https://github.com/gorhom/react-native-portal/issues/3
14
- * https://github.com/gorhom/react-native-portal/issues/31
15
- *
16
- * @component
17
- * @param {object} props - The component props.
18
- * @param {React.ReactNode} props.children - The content to render within the portal.
19
- * @returns {React.ReactPortal} The React portal component.
20
- */
21
-
22
- const WebPortal = _ref => {
23
- let {
24
- children
25
- } = _ref;
26
- const portalContainer = document.createElement('div');
27
- useEffect(() => {
28
- document.body.appendChild(portalContainer);
29
- return () => {
30
- document.body.removeChild(portalContainer);
31
- };
32
- }, [portalContainer]);
33
- return /*#__PURE__*/ReactDOM.createPortal(children, portalContainer);
34
- };
35
- export default WebPortal;
@@ -1,2 +0,0 @@
1
- import WebPortal from './WebPortal';
2
- export default WebPortal;
@@ -1,36 +0,0 @@
1
- import { useEffect } from 'react'
2
- import ReactDOM from 'react-dom'
3
-
4
- /**
5
- * WebPortal component renders its children in a separate portal container appended to the document body.
6
- *
7
- * While `@gorhom/portal` works well for a lot of use-cases, there are some issues with it, particularly around
8
- * reading context values (see issues below). For web-only components, it is safe to replace `Portal` from `@gorhom/portal`
9
- * to `WebPortal` to solve such issues
10
- *
11
- * https://github.com/gorhom/react-native-portal/issues/34
12
- * https://github.com/gorhom/react-native-portal/issues/2
13
- * https://github.com/gorhom/react-native-portal/issues/3
14
- * https://github.com/gorhom/react-native-portal/issues/31
15
- *
16
- * @component
17
- * @param {object} props - The component props.
18
- * @param {React.ReactNode} props.children - The content to render within the portal.
19
- * @returns {React.ReactPortal} The React portal component.
20
- */
21
-
22
- const WebPortal = ({ children }) => {
23
- const portalContainer = document.createElement('div')
24
-
25
- useEffect(() => {
26
- document.body.appendChild(portalContainer)
27
-
28
- return () => {
29
- document.body.removeChild(portalContainer)
30
- }
31
- }, [portalContainer])
32
-
33
- return ReactDOM.createPortal(children, portalContainer)
34
- }
35
-
36
- export default WebPortal
@@ -1,3 +0,0 @@
1
- import WebPortal from './WebPortal'
2
-
3
- export default WebPortal