@telus-uds/components-web 2.32.0 → 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 +12 -2
- package/lib/DatePicker/DatePicker.js +1 -2
- package/lib/NavigationBar/NavigationSubMenu.js +10 -5
- package/lib/baseExports.js +12 -0
- package/lib/index.js +1 -9
- package/lib-module/DatePicker/DatePicker.js +2 -3
- package/lib-module/NavigationBar/NavigationSubMenu.js +10 -5
- package/lib-module/baseExports.js +5 -2
- package/lib-module/index.js +0 -1
- package/package.json +2 -2
- package/src/DatePicker/DatePicker.jsx +3 -3
- package/src/NavigationBar/NavigationSubMenu.jsx +4 -3
- package/src/baseExports.js +4 -0
- package/src/index.js +0 -1
- package/lib/WebPortal/WebPortal.js +0 -51
- package/lib/WebPortal/index.js +0 -10
- package/lib-module/WebPortal/WebPortal.js +0 -44
- package/lib-module/WebPortal/index.js +0 -2
- package/src/WebPortal/WebPortal.jsx +0 -47
- package/src/WebPortal/index.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
# Change Log - @telus-uds/components-web
|
|
2
2
|
|
|
3
|
-
This log was last generated on Tue,
|
|
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
|
+
|
|
7
17
|
## 2.32.0
|
|
8
18
|
|
|
9
|
-
Tue, 12 Mar 2024 22:
|
|
19
|
+
Tue, 12 Mar 2024 22:26:51 GMT
|
|
10
20
|
|
|
11
21
|
### Minor changes
|
|
12
22
|
|
|
@@ -17,7 +17,6 @@ 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"));
|
|
21
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
22
|
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); }
|
|
@@ -329,7 +328,7 @@ const DatePicker = /*#__PURE__*/(0, _react.forwardRef)((_ref3, ref) => {
|
|
|
329
328
|
validation: validation,
|
|
330
329
|
inactive: disabled,
|
|
331
330
|
ref: textInputRef,
|
|
332
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
331
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_componentsBase.Portal, {
|
|
333
332
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PortalPositionedContainer, {
|
|
334
333
|
top: datePickerPosition.top,
|
|
335
334
|
left: datePickerPosition.left,
|
|
@@ -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: '
|
|
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: '
|
|
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
|
});
|
package/lib/baseExports.js
CHANGED
|
@@ -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,13 +5,12 @@ 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, 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';
|
|
12
12
|
import dictionary from './dictionary';
|
|
13
13
|
import { htmlAttrs } from '../utils';
|
|
14
|
-
import WebPortal from '../WebPortal';
|
|
15
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
16
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -322,7 +321,7 @@ const DatePicker = /*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
|
322
321
|
validation: validation,
|
|
323
322
|
inactive: disabled,
|
|
324
323
|
ref: textInputRef,
|
|
325
|
-
children: /*#__PURE__*/_jsx(
|
|
324
|
+
children: /*#__PURE__*/_jsx(Portal, {
|
|
326
325
|
children: /*#__PURE__*/_jsx(PortalPositionedContainer, {
|
|
327
326
|
top: datePickerPosition.top,
|
|
328
327
|
left: datePickerPosition.left,
|
|
@@ -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: '
|
|
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: '
|
|
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';
|
package/lib-module/index.js
CHANGED
|
@@ -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.80.
|
|
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.32.
|
|
86
|
+
"version": "2.32.1"
|
|
87
87
|
}
|
|
@@ -8,6 +8,7 @@ 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,
|
|
@@ -21,7 +22,6 @@ import { isUndefined, throttle } from 'lodash'
|
|
|
21
22
|
import CalendarContainer from './CalendarContainer'
|
|
22
23
|
import dictionary from './dictionary'
|
|
23
24
|
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'
|
|
@@ -294,7 +294,7 @@ const DatePicker = forwardRef(
|
|
|
294
294
|
inactive={disabled}
|
|
295
295
|
ref={textInputRef}
|
|
296
296
|
>
|
|
297
|
-
<
|
|
297
|
+
<Portal>
|
|
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
|
-
</
|
|
362
|
+
</Portal>
|
|
363
363
|
</TextInput>
|
|
364
364
|
</DateInputWrapper>
|
|
365
365
|
)}
|
|
@@ -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: '
|
|
30
|
-
sm: { align: { top: '
|
|
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
|
})
|
package/src/baseExports.js
CHANGED
|
@@ -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,51 +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
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
/**
|
|
12
|
-
* WebPortal component renders its children in a separate portal container appended to the document body.
|
|
13
|
-
*
|
|
14
|
-
* While `@gorhom/portal` works well for a lot of use-cases, there are some issues with it, particularly around
|
|
15
|
-
* reading context values (see issues below). For web-only components, it is safe to replace `Portal` from `@gorhom/portal`
|
|
16
|
-
* to `WebPortal` to solve such issues
|
|
17
|
-
*
|
|
18
|
-
* https://github.com/gorhom/react-native-portal/issues/34
|
|
19
|
-
* https://github.com/gorhom/react-native-portal/issues/2
|
|
20
|
-
* https://github.com/gorhom/react-native-portal/issues/3
|
|
21
|
-
* https://github.com/gorhom/react-native-portal/issues/31
|
|
22
|
-
*
|
|
23
|
-
* @component
|
|
24
|
-
* @param {object} props - The component props.
|
|
25
|
-
* @param {React.ReactNode} props.children - The content to render within the portal.
|
|
26
|
-
* @returns {React.ReactPortal} The React portal component.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
const WebPortal = _ref => {
|
|
30
|
-
let {
|
|
31
|
-
children
|
|
32
|
-
} = _ref;
|
|
33
|
-
const [portalContainer, setPortalContainer] = (0, _react.useState)(null);
|
|
34
|
-
(0, _react.useEffect)(() => {
|
|
35
|
-
const container = document.createElement('div');
|
|
36
|
-
document.body.appendChild(container);
|
|
37
|
-
setPortalContainer(container);
|
|
38
|
-
return () => {
|
|
39
|
-
if (container && container.parentNode) {
|
|
40
|
-
container.parentNode.removeChild(container);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}, []);
|
|
44
|
-
if (!portalContainer) return null;
|
|
45
|
-
return /*#__PURE__*/_reactDom.default.createPortal(children, portalContainer);
|
|
46
|
-
};
|
|
47
|
-
WebPortal.propTypes = {
|
|
48
|
-
children: _propTypes.default.node.isRequired
|
|
49
|
-
};
|
|
50
|
-
var _default = WebPortal;
|
|
51
|
-
exports.default = _default;
|
package/lib/WebPortal/index.js
DELETED
|
@@ -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,44 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* WebPortal component renders its children in a separate portal container appended to the document body.
|
|
7
|
-
*
|
|
8
|
-
* While `@gorhom/portal` works well for a lot of use-cases, there are some issues with it, particularly around
|
|
9
|
-
* reading context values (see issues below). For web-only components, it is safe to replace `Portal` from `@gorhom/portal`
|
|
10
|
-
* to `WebPortal` to solve such issues
|
|
11
|
-
*
|
|
12
|
-
* https://github.com/gorhom/react-native-portal/issues/34
|
|
13
|
-
* https://github.com/gorhom/react-native-portal/issues/2
|
|
14
|
-
* https://github.com/gorhom/react-native-portal/issues/3
|
|
15
|
-
* https://github.com/gorhom/react-native-portal/issues/31
|
|
16
|
-
*
|
|
17
|
-
* @component
|
|
18
|
-
* @param {object} props - The component props.
|
|
19
|
-
* @param {React.ReactNode} props.children - The content to render within the portal.
|
|
20
|
-
* @returns {React.ReactPortal} The React portal component.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
const WebPortal = _ref => {
|
|
24
|
-
let {
|
|
25
|
-
children
|
|
26
|
-
} = _ref;
|
|
27
|
-
const [portalContainer, setPortalContainer] = useState(null);
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const container = document.createElement('div');
|
|
30
|
-
document.body.appendChild(container);
|
|
31
|
-
setPortalContainer(container);
|
|
32
|
-
return () => {
|
|
33
|
-
if (container && container.parentNode) {
|
|
34
|
-
container.parentNode.removeChild(container);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}, []);
|
|
38
|
-
if (!portalContainer) return null;
|
|
39
|
-
return /*#__PURE__*/ReactDOM.createPortal(children, portalContainer);
|
|
40
|
-
};
|
|
41
|
-
WebPortal.propTypes = {
|
|
42
|
-
children: PropTypes.node.isRequired
|
|
43
|
-
};
|
|
44
|
-
export default WebPortal;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react'
|
|
2
|
-
import ReactDOM from 'react-dom'
|
|
3
|
-
import PropTypes from 'prop-types'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* WebPortal component renders its children in a separate portal container appended to the document body.
|
|
7
|
-
*
|
|
8
|
-
* While `@gorhom/portal` works well for a lot of use-cases, there are some issues with it, particularly around
|
|
9
|
-
* reading context values (see issues below). For web-only components, it is safe to replace `Portal` from `@gorhom/portal`
|
|
10
|
-
* to `WebPortal` to solve such issues
|
|
11
|
-
*
|
|
12
|
-
* https://github.com/gorhom/react-native-portal/issues/34
|
|
13
|
-
* https://github.com/gorhom/react-native-portal/issues/2
|
|
14
|
-
* https://github.com/gorhom/react-native-portal/issues/3
|
|
15
|
-
* https://github.com/gorhom/react-native-portal/issues/31
|
|
16
|
-
*
|
|
17
|
-
* @component
|
|
18
|
-
* @param {object} props - The component props.
|
|
19
|
-
* @param {React.ReactNode} props.children - The content to render within the portal.
|
|
20
|
-
* @returns {React.ReactPortal} The React portal component.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
const WebPortal = ({ children }) => {
|
|
24
|
-
const [portalContainer, setPortalContainer] = useState(null)
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
const container = document.createElement('div')
|
|
28
|
-
document.body.appendChild(container)
|
|
29
|
-
setPortalContainer(container)
|
|
30
|
-
|
|
31
|
-
return () => {
|
|
32
|
-
if (container && container.parentNode) {
|
|
33
|
-
container.parentNode.removeChild(container)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}, [])
|
|
37
|
-
|
|
38
|
-
if (!portalContainer) return null
|
|
39
|
-
|
|
40
|
-
return ReactDOM.createPortal(children, portalContainer)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
WebPortal.propTypes = {
|
|
44
|
-
children: PropTypes.node.isRequired
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default WebPortal
|
package/src/WebPortal/index.js
DELETED