@telus-uds/components-web 2.18.0 → 2.19.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +11 -2
  2. package/component-docs.json +381 -471
  3. package/lib/NavigationBar/NavigationSubMenu.js +2 -4
  4. package/lib/baseExports.js +12 -0
  5. package/lib/index.js +0 -18
  6. package/lib/utils/useOverlaidPosition.js +2 -2
  7. package/lib-module/NavigationBar/NavigationSubMenu.js +1 -2
  8. package/lib-module/baseExports.js +1 -1
  9. package/lib-module/index.js +0 -2
  10. package/lib-module/utils/useOverlaidPosition.js +2 -2
  11. package/package.json +2 -2
  12. package/src/NavigationBar/NavigationSubMenu.jsx +1 -2
  13. package/src/baseExports.js +2 -0
  14. package/src/index.js +0 -2
  15. package/src/utils/useOverlaidPosition.js +2 -2
  16. package/lib/Autocomplete/Autocomplete.js +0 -430
  17. package/lib/Autocomplete/Loading.js +0 -46
  18. package/lib/Autocomplete/Suggestions.js +0 -81
  19. package/lib/Autocomplete/constants.js +0 -19
  20. package/lib/Autocomplete/dictionary.js +0 -19
  21. package/lib/Autocomplete/index.js +0 -13
  22. package/lib/Listbox/GroupControl.js +0 -110
  23. package/lib/Listbox/Listbox.js +0 -185
  24. package/lib/Listbox/ListboxGroup.js +0 -145
  25. package/lib/Listbox/ListboxItem.js +0 -101
  26. package/lib/Listbox/ListboxOverlay.js +0 -91
  27. package/lib/Listbox/index.js +0 -13
  28. package/lib-module/Autocomplete/Autocomplete.js +0 -406
  29. package/lib-module/Autocomplete/Loading.js +0 -32
  30. package/lib-module/Autocomplete/Suggestions.js +0 -64
  31. package/lib-module/Autocomplete/constants.js +0 -5
  32. package/lib-module/Autocomplete/dictionary.js +0 -12
  33. package/lib-module/Autocomplete/index.js +0 -2
  34. package/lib-module/Listbox/GroupControl.js +0 -96
  35. package/lib-module/Listbox/Listbox.js +0 -164
  36. package/lib-module/Listbox/ListboxGroup.js +0 -122
  37. package/lib-module/Listbox/ListboxItem.js +0 -77
  38. package/lib-module/Listbox/ListboxOverlay.js +0 -69
  39. package/lib-module/Listbox/index.js +0 -2
  40. package/src/Autocomplete/Autocomplete.jsx +0 -375
  41. package/src/Autocomplete/Loading.jsx +0 -15
  42. package/src/Autocomplete/Suggestions.jsx +0 -52
  43. package/src/Autocomplete/constants.js +0 -6
  44. package/src/Autocomplete/dictionary.js +0 -12
  45. package/src/Autocomplete/index.js +0 -3
  46. package/src/Listbox/GroupControl.jsx +0 -82
  47. package/src/Listbox/Listbox.jsx +0 -169
  48. package/src/Listbox/ListboxGroup.jsx +0 -125
  49. package/src/Listbox/ListboxItem.jsx +0 -80
  50. package/src/Listbox/ListboxOverlay.jsx +0 -72
  51. package/src/Listbox/index.js +0 -3
@@ -1,64 +0,0 @@
1
- import React, { forwardRef } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { A11yText, Box, Typography } from '@telus-uds/components-base';
4
- import Listbox from '../Listbox';
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- import { Fragment as _Fragment } from "react/jsx-runtime";
7
- import { jsxs as _jsxs } from "react/jsx-runtime";
8
- const Suggestions = /*#__PURE__*/forwardRef((_ref, ref) => {
9
- let {
10
- hasResults,
11
- items = [],
12
- noResults,
13
- onClose,
14
- onSelect,
15
- parentRef
16
- } = _ref;
17
- const pressableItems = items.map(_ref2 => {
18
- let {
19
- id,
20
- ...rest
21
- } = _ref2;
22
- return {
23
- id,
24
- onPress: () => onSelect(id),
25
- ...rest
26
- };
27
- });
28
- if (items !== null && items !== void 0 && items.length) return /*#__PURE__*/_jsxs(_Fragment, {
29
- children: [/*#__PURE__*/_jsx(A11yText, {
30
- accessibilityLiveRegion: "polite",
31
- text: hasResults
32
- }), /*#__PURE__*/_jsx(Listbox, {
33
- items: pressableItems,
34
- firstItemRef: ref,
35
- parentRef: parentRef,
36
- onClose: onClose
37
- })]
38
- });
39
- return /*#__PURE__*/_jsx(Box, {
40
- space: 3,
41
- children: typeof noResults === 'string' ? /*#__PURE__*/_jsx(_Fragment, {
42
- children: /*#__PURE__*/_jsx(Typography, {
43
- accessibilityLiveRegion: "polite",
44
- variant: {
45
- size: 'small'
46
- },
47
- children: noResults
48
- })
49
- }) : noResults
50
- });
51
- });
52
- Suggestions.displayName = 'Suggestions';
53
- Suggestions.propTypes = {
54
- hasResults: PropTypes.string.isRequired,
55
- items: PropTypes.arrayOf(PropTypes.shape({
56
- id: PropTypes.string,
57
- label: PropTypes.node
58
- })).isRequired,
59
- noResults: PropTypes.node.isRequired,
60
- onClose: PropTypes.func.isRequired,
61
- onSelect: PropTypes.func.isRequired,
62
- parentRef: PropTypes.object.isRequired
63
- };
64
- export default Suggestions;
@@ -1,5 +0,0 @@
1
- import palette from '@telus-uds/palette-allium/build/web/palette';
2
- export const DEFAULT_MIN_TO_SUGGESTION = 1;
3
- export const DEFAULT_MAX_SUGGESTIONS = 5;
4
- export const INPUT_LEFT_PADDING = palette.size.size16;
5
- export const MIN_LISTBOX_WIDTH = palette.size.size288;
@@ -1,12 +0,0 @@
1
- export default {
2
- en: {
3
- hasResults: 'Some results are available',
4
- loading: 'Searching...',
5
- noResults: 'No results found'
6
- },
7
- fr: {
8
- hasResults: 'Quelques suggestions sont disponible',
9
- loading: 'Recherche...',
10
- noResults: 'Aucun résultat trouvé'
11
- }
12
- };
@@ -1,2 +0,0 @@
1
- import Autocomplete from './Autocomplete';
2
- export default Autocomplete;
@@ -1,96 +0,0 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
- import PropTypes from 'prop-types';
4
- import { Icon, Spacer, useThemeTokens, useListboxContext } from '@telus-uds/components-base';
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- import { jsxs as _jsxs } from "react/jsx-runtime";
7
- const StyledControlWrapper = /*#__PURE__*/styled.div.withConfig({
8
- displayName: "GroupControl__StyledControlWrapper",
9
- componentId: "components-web__sc-1r7ts3q-0"
10
- })(_ref => {
11
- let {
12
- groupFontName,
13
- groupFontWeight,
14
- groupFontSize,
15
- groupColor,
16
- groupBackgroundColor,
17
- groupBorderColor,
18
- groupBorderWidth,
19
- groupBorderRadius,
20
- groupPaddingLeft,
21
- groupPaddingRight,
22
- groupPaddingTop,
23
- groupPaddingBottom,
24
- itemTextDecoration,
25
- itemOutline,
26
- groupHeight
27
- } = _ref;
28
- return {
29
- fontFamily: `${groupFontName}${groupFontWeight}normal`,
30
- fontSize: groupFontSize,
31
- color: groupColor,
32
- textDecoration: itemTextDecoration,
33
- backgroundColor: groupBackgroundColor,
34
- outline: itemOutline,
35
- width: '100%',
36
- height: groupHeight,
37
- display: 'flex',
38
- alignItems: 'center',
39
- justifyContent: 'space-between',
40
- boxSizing: 'border-box',
41
- border: `${groupBorderWidth}px solid ${groupBorderColor}`,
42
- borderRadius: groupBorderRadius,
43
- paddingLeft: groupPaddingLeft - groupBorderWidth,
44
- paddingRight: groupPaddingRight - groupBorderWidth,
45
- paddingTop: groupPaddingTop - groupBorderWidth,
46
- paddingBottom: groupPaddingBottom - groupBorderWidth
47
- };
48
- });
49
-
50
- const GroupControl = _ref2 => {
51
- let {
52
- expanded,
53
- pressed,
54
- hover,
55
- focus,
56
- label,
57
- id
58
- } = _ref2;
59
- const {
60
- selectedId,
61
- setSelectedId
62
- } = useListboxContext();
63
- const tokens = useThemeTokens('Listbox', {}, {}, {
64
- expanded,
65
- pressed,
66
- hover,
67
- current: selectedId === id && id !== undefined,
68
- focus
69
- });
70
- return /*#__PURE__*/_jsxs(StyledControlWrapper, {
71
- onClick: () => setSelectedId(id),
72
- ...tokens,
73
- children: [label, /*#__PURE__*/_jsx(Spacer, {
74
- space: 1,
75
- direction: "row"
76
- }), /*#__PURE__*/_jsx(Icon, {
77
- icon: tokens.groupIcon,
78
- tokens: {
79
- color: tokens.groupColor
80
- },
81
- variant: {
82
- size: 'micro'
83
- }
84
- })]
85
- });
86
- };
87
-
88
- GroupControl.propTypes = {
89
- id: PropTypes.string,
90
- expanded: PropTypes.bool,
91
- pressed: PropTypes.bool,
92
- hover: PropTypes.bool,
93
- focus: PropTypes.bool,
94
- label: PropTypes.string
95
- };
96
- export default GroupControl;
@@ -1,164 +0,0 @@
1
- import React, { useCallback, useEffect, useRef, useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
4
- import { ExpandCollapse, useThemeTokens, withLinkRouter, ListboxContext, getTokensPropType } from '@telus-uds/components-base';
5
- import ListboxGroup from './ListboxGroup';
6
- import ListboxItem from './ListboxItem';
7
- import DropdownOverlay from './ListboxOverlay';
8
- import { createElement as _createElement } from "react";
9
- import { jsx as _jsx } from "react/jsx-runtime";
10
- const StyledList = /*#__PURE__*/styled.ul.withConfig({
11
- displayName: "Listbox__StyledList",
12
- componentId: "components-web__sc-1564thh-0"
13
- })({
14
- margin: 0,
15
- padding: 0,
16
- listStyle: 'none'
17
- });
18
-
19
- const getInitialOpen = (items, selectedId) => items.filter(item => item.items && item.items.some(nestedItem => (nestedItem.id ?? nestedItem.label) === selectedId)).map(item => item.id ?? item.label);
20
-
21
- const Listbox = _ref => {
22
- let {
23
- items = [],
24
- firstItemRef = null,
25
- // focus will be moved to this one once within the menu
26
- parentRef = null,
27
- // to return focus to after leaving the last menu item
28
- selectedId: defaultSelectedId,
29
- LinkRouter,
30
- itemRouterProps,
31
- onClose,
32
- variant,
33
- tokens
34
- } = _ref;
35
- const initialOpen = getInitialOpen(items, defaultSelectedId);
36
- const [selectedId, setSelectedId] = useState(defaultSelectedId);
37
- const {
38
- minHeight,
39
- minWidth
40
- } = useThemeTokens('Listbox', variant, tokens); // We need to keep track of each item's ref in order to be able to
41
- // focus on a specific item via keyboard navigation
42
-
43
- const itemRefs = useRef([]);
44
- if (firstItemRef !== null && firstItemRef !== void 0 && firstItemRef.current) itemRefs.current[0] = firstItemRef.current;
45
- const [focusedIndex, setFocusedIndex] = useState(0);
46
- const handleKeydown = useCallback(event => {
47
- const nextItemRef = itemRefs.current[focusedIndex + 1];
48
- const prevItemRef = itemRefs.current[focusedIndex - 1];
49
-
50
- if (event.key === 'ArrowUp' || event.shiftKey && event.key === 'Tab') {
51
- var _parentRef$current;
52
-
53
- // Move the focus to the previous item or to the parent one if on the first
54
- if (prevItemRef) {
55
- event.preventDefault();
56
- prevItemRef.focus();
57
- } else if (parentRef) (_parentRef$current = parentRef.current) === null || _parentRef$current === void 0 ? void 0 : _parentRef$current.focus();
58
-
59
- setFocusedIndex(focusedIndex - 1);
60
- } else if ((event.key === 'ArrowDown' || event.key === 'Tab') && nextItemRef) {
61
- event.preventDefault();
62
- setFocusedIndex(focusedIndex + 1);
63
- nextItemRef.focus();
64
- } else if (event.key === 'Escape') {
65
- var _parentRef$current2, _parentRef$current3;
66
-
67
- // Close the dropdown
68
- parentRef === null || parentRef === void 0 ? void 0 : (_parentRef$current2 = parentRef.current) === null || _parentRef$current2 === void 0 ? void 0 : _parentRef$current2.click(); // Return focus to the dropdown control after leaving the last item
69
-
70
- parentRef === null || parentRef === void 0 ? void 0 : (_parentRef$current3 = parentRef.current) === null || _parentRef$current3 === void 0 ? void 0 : _parentRef$current3.focus();
71
- if (onClose) onClose(event);
72
- }
73
- }, [focusedIndex, onClose, parentRef]); // Add listeners for mouse clicks outside and for key presses
74
-
75
- useEffect(() => {
76
- window.addEventListener('click', onClose);
77
- window.addEventListener('keydown', handleKeydown);
78
- window.addEventListener('touchstart', onClose);
79
- return () => {
80
- window.removeEventListener('click', onClose);
81
- window.removeEventListener('keydown', handleKeydown);
82
- window.removeEventListener('touchstart', onClose);
83
- };
84
- }, [onClose, handleKeydown]);
85
- return /*#__PURE__*/_jsx(ListboxContext.Provider, {
86
- value: {
87
- selectedId,
88
- setSelectedId
89
- },
90
- children: /*#__PURE__*/_jsx(ExpandCollapse, {
91
- initialOpen: initialOpen,
92
- maxOpen: 1,
93
- children: expandProps => /*#__PURE__*/_jsx(StyledList, {
94
- role: "listbox",
95
- style: {
96
- minHeight,
97
- minWidth
98
- },
99
- children: items.map((item, index) => {
100
- const {
101
- id,
102
- label,
103
- items: nestedItems
104
- } = item;
105
- const itemId = id ?? label; // Give `firstItemRef` to the first focusable item
106
-
107
- const itemRef = index === 0 && !itemId !== selectedId || index === 1 && items[0].id === selectedId ? firstItemRef : ref => {
108
- itemRefs.current[index] = ref;
109
- return ref;
110
- };
111
- return nestedItems ? /*#__PURE__*/_createElement(ListboxGroup, { ...item,
112
- expandProps: expandProps,
113
- LinkRouter: LinkRouter,
114
- itemRouterProps: itemRouterProps,
115
- prevItemRef: itemRefs.current[index - 1] ?? null,
116
- nextItemRef: itemRefs.current[index + 1] ?? null,
117
- ref: itemRef,
118
- key: itemId
119
- }) : /*#__PURE__*/_createElement(ListboxItem, { ...item,
120
- key: itemId,
121
- id: itemId,
122
- LinkRouter: LinkRouter,
123
- itemRouterProps: itemRouterProps,
124
- prevItemRef: itemRefs.current[index - 1] ?? null,
125
- nextItemRef: itemRefs.current[index + 1] ?? null,
126
- ref: itemRef
127
- });
128
- })
129
- })
130
- })
131
- });
132
- };
133
-
134
- Listbox.propTypes = { ...withLinkRouter.propTypes,
135
-
136
- /**
137
- * Focus will be moved to the item with this ref once within the menu.
138
- */
139
- firstItemRef: PropTypes.object,
140
-
141
- /**
142
- * Focus will be returned to the dropdown control with this ref after leaving
143
- * the last menu item.
144
- */
145
- parentRef: PropTypes.object,
146
-
147
- /**
148
- * `Listbox` items
149
- */
150
- items: PropTypes.array,
151
-
152
- /**
153
- * To select an item by default
154
- */
155
- selectedId: PropTypes.string,
156
-
157
- /**
158
- * onClose event
159
- */
160
- onClose: PropTypes.func,
161
- tokens: getTokensPropType('Listbox')
162
- };
163
- Listbox.Overlay = DropdownOverlay;
164
- export default Listbox;
@@ -1,122 +0,0 @@
1
- /* eslint-disable react/require-default-props */
2
- import React, { forwardRef } from 'react';
3
- import PropTypes from 'prop-types';
4
- import { ExpandCollapse, withLinkRouter, useListboxContext } from '@telus-uds/components-base';
5
- import styled from 'styled-components';
6
- import ListboxItem from './ListboxItem';
7
- import GroupControl from './GroupControl';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- const StyledGroupWrapper = /*#__PURE__*/styled.li.withConfig({
10
- displayName: "ListboxGroup__StyledGroupWrapper",
11
- componentId: "components-web__sc-3jlyy7-0"
12
- })({
13
- margin: 'none',
14
- padding: 'none',
15
- display: 'block',
16
- overflowY: 'hidden',
17
- // Currently the default expand collapse control does not have a focus state and so the browser default is applied.
18
- // This hides the outline so that it does not clash with the custom control we provide.
19
- '& div[role=button]': {
20
- outline: 'none'
21
- }
22
- });
23
- const StyledList = /*#__PURE__*/styled.ul.withConfig({
24
- displayName: "ListboxGroup__StyledList",
25
- componentId: "components-web__sc-3jlyy7-1"
26
- })({
27
- margin: 0,
28
- padding: 0,
29
- listStyle: 'none'
30
- });
31
- const ListboxGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
32
- let {
33
- id,
34
- label,
35
- items,
36
- LinkRouter,
37
- linkRouterProps,
38
- expandProps,
39
- onLastItemBlur,
40
- nextItemRef,
41
- prevItemRef
42
- } = _ref;
43
- const {
44
- selectedId
45
- } = useListboxContext(); // TODO: implement keyboard navigation via refs for grouped items separately here
46
-
47
- return /*#__PURE__*/_jsx(StyledGroupWrapper, {
48
- role: "option",
49
- children: /*#__PURE__*/_jsx(ExpandCollapse.Panel, {
50
- panelId: id ?? label,
51
- controlTokens: {
52
- icon: null,
53
- paddingLeft: 'none',
54
- paddingRight: 'none',
55
- paddingTop: 'none',
56
- paddingBottom: 'none',
57
- backgroundColor: 'transparent',
58
- borderColor: 'transparent',
59
- textLine: 'none',
60
- borderWidth: 0
61
- } // TODO refactor
62
- // eslint-disable-next-line react/no-unstable-nested-components
63
- ,
64
- control: controlProps => /*#__PURE__*/_jsx(GroupControl, {
65
- id: id ?? label,
66
- ...controlProps,
67
- label: label
68
- }),
69
- ...expandProps,
70
- tokens: {
71
- contentPaddingLeft: 'none',
72
- contentPaddingRight: 'none',
73
- contentPaddingTop: 'none',
74
- contentPaddingBottom: 'none',
75
- borderColor: 'transparent',
76
- borderRadius: 0,
77
- borderWidth: 0,
78
- marginBottom: 0
79
- },
80
- controlRef: ref,
81
- children: /*#__PURE__*/_jsx(StyledList, {
82
- children: items.map((item, index) => {
83
- return /*#__PURE__*/_jsx(ListboxItem, {
84
- id: item.id ?? item.label,
85
- ...item,
86
- selected: item.id && item.id === selectedId || item.label && item.label === selectedId,
87
- isChild: true,
88
- LinkRouter: LinkRouter,
89
- linkRouterProps: linkRouterProps,
90
- ...(index === 0 && {
91
- prevItemRef
92
- }),
93
- ...(index === items.length - 1 && {
94
- nextItemRef
95
- }),
96
- ...(index === items.length - 1 && {
97
- onBlur: onLastItemBlur
98
- })
99
- }, item.label);
100
- })
101
- })
102
- })
103
- });
104
- });
105
- ListboxGroup.displayName = 'ListboxGroup';
106
- ListboxGroup.propTypes = { ...withLinkRouter.propTypes,
107
- label: PropTypes.string,
108
- items: PropTypes.arrayOf(PropTypes.shape({
109
- href: PropTypes.string,
110
- label: PropTypes.string,
111
- current: PropTypes.bool
112
- })),
113
- expandProps: PropTypes.object,
114
- nextItemRef: PropTypes.object,
115
- prevItemRef: PropTypes.object,
116
-
117
- /**
118
- * Use this callback to redirect the focus after it leaves the last item of the group.
119
- */
120
- onLastItemBlur: PropTypes.func
121
- };
122
- export default ListboxGroup;
@@ -1,77 +0,0 @@
1
- /* eslint-disable react/require-default-props */
2
- import React, { forwardRef } from 'react';
3
- import PropTypes from 'prop-types';
4
- import styled from 'styled-components';
5
- import { selectSystemProps, withLinkRouter, useThemeTokensCallback, PressableItem } from '@telus-uds/components-base';
6
- import { htmlAttrs } from '../utils';
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
9
- const StyledItemContainer = /*#__PURE__*/styled.li.withConfig({
10
- displayName: "ListboxItem__StyledItemContainer",
11
- componentId: "components-web__sc-tlroet-0"
12
- })({
13
- display: 'flex',
14
- paddingLeft: _ref => {
15
- let {
16
- isChild
17
- } = _ref;
18
- return isChild ? '16px' : '0px';
19
- },
20
- '&&&': {
21
- // Docusaurus applies aggressively high-specificity margin on `li`
22
- margin: 0
23
- }
24
- });
25
- const ListboxItem = /*#__PURE__*/forwardRef((_ref2, ref) => {
26
- let {
27
- href,
28
- label,
29
- isChild = false,
30
- onBlur,
31
- nextItemRef,
32
- prevItemRef,
33
- tokens,
34
- variant = {},
35
- LinkRouter,
36
- linkRouterProps,
37
- id,
38
- onPress = () => {},
39
- ...rest
40
- } = _ref2;
41
- const selectedProps = selectProps({
42
- href,
43
- ...rest
44
- });
45
- const getTokens = useThemeTokensCallback('Listbox', tokens, variant, {
46
- isChild
47
- });
48
- return /*#__PURE__*/_jsx(StyledItemContainer, {
49
- isChild: isChild,
50
- ...selectedProps,
51
- role: "option",
52
- children: /*#__PURE__*/_jsx(PressableItem, {
53
- href: href,
54
- isChild: isChild,
55
- onPress: onPress,
56
- onBlur: onBlur,
57
- nextItemRef: nextItemRef,
58
- prevItemRef: prevItemRef,
59
- ref: ref,
60
- tokens: getTokens,
61
- selectedProps: selectedProps,
62
- id: id,
63
- children: label
64
- })
65
- });
66
- });
67
- ListboxItem.displayName = 'ListboxItem';
68
- ListboxItem.propTypes = { ...selectedSystemPropTypes,
69
- ...withLinkRouter.propTypes,
70
- href: PropTypes.string,
71
- isChild: PropTypes.bool,
72
- label: PropTypes.node.isRequired,
73
- nextItemRef: PropTypes.object,
74
- prevItemRef: PropTypes.object,
75
- onPress: PropTypes.func
76
- };
77
- export default withLinkRouter(ListboxItem);
@@ -1,69 +0,0 @@
1
- /* eslint-disable react/require-default-props */
2
- import React, { forwardRef } from 'react';
3
- import { Card, useThemeTokens } from '@telus-uds/components-base';
4
- import PropTypes from 'prop-types';
5
- import View from "react-native-web/dist/exports/View";
6
- import StyleSheet from "react-native-web/dist/exports/StyleSheet";
7
- import WebPortal from '../WebPortal';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- const staticStyles = StyleSheet.create({
10
- positioner: {
11
- flex: 1,
12
- // Grow to maxWidth when possible, shrink when not possible
13
- position: 'absolute',
14
- zIndex: 10000 // Position on top of all the other overlays, including backdrops and modals
15
-
16
- },
17
- hidden: {
18
- // Use opacity not visibility to hide the dropdown during positioning
19
- // so on web, children may be focused from the first render
20
- opacity: 0
21
- }
22
- });
23
- const paddingVertical = 0;
24
- const paddingHorizontal = 0;
25
- const DropdownOverlay = /*#__PURE__*/forwardRef((_ref, ref) => {
26
- let {
27
- children,
28
- isReady = false,
29
- overlaidPosition,
30
- maxWidth,
31
- minWidth,
32
- onLayout
33
- } = _ref;
34
- const systemTokens = useThemeTokens('Listbox', {}, {});
35
- return /*#__PURE__*/_jsx(WebPortal, {
36
- children: /*#__PURE__*/_jsx(View, {
37
- ref: ref,
38
- onLayout: onLayout,
39
- style: [overlaidPosition, {
40
- maxWidth,
41
- minWidth
42
- }, staticStyles.positioner, !isReady && staticStyles.hidden],
43
- children: /*#__PURE__*/_jsx(Card, {
44
- tokens: {
45
- shadow: systemTokens.shadow,
46
- paddingBottom: paddingVertical,
47
- paddingTop: paddingVertical,
48
- paddingLeft: paddingHorizontal,
49
- paddingRight: paddingHorizontal
50
- },
51
- children: children
52
- })
53
- })
54
- });
55
- });
56
- DropdownOverlay.displayName = 'DropdownOverlay';
57
- DropdownOverlay.propTypes = {
58
- children: PropTypes.node.isRequired,
59
- isReady: PropTypes.bool,
60
- overlaidPosition: PropTypes.shape({
61
- top: PropTypes.number,
62
- left: PropTypes.number,
63
- width: PropTypes.number
64
- }),
65
- maxWidth: PropTypes.number,
66
- minWidth: PropTypes.number,
67
- onLayout: PropTypes.func
68
- };
69
- export default DropdownOverlay;
@@ -1,2 +0,0 @@
1
- import Listbox from './Listbox';
2
- export default Listbox;