@telus-uds/components-base 1.60.0 → 1.61.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 +10 -2
  2. package/component-docs.json +281 -70
  3. package/lib/Autocomplete/Autocomplete.js +483 -0
  4. package/lib/Autocomplete/Loading.js +51 -0
  5. package/lib/Autocomplete/Suggestions.js +85 -0
  6. package/lib/Autocomplete/constants.js +14 -0
  7. package/lib/Autocomplete/dictionary.js +19 -0
  8. package/lib/Autocomplete/index.js +13 -0
  9. package/lib/Listbox/GroupControl.js +121 -0
  10. package/lib/Listbox/Listbox.js +198 -0
  11. package/lib/Listbox/ListboxGroup.js +142 -0
  12. package/lib/Listbox/ListboxItem.js +97 -0
  13. package/lib/Listbox/ListboxOverlay.js +106 -0
  14. package/lib/Listbox/PressableItem.js +0 -2
  15. package/lib/Listbox/index.js +5 -24
  16. package/lib/TextInput/TextInputBase.js +2 -0
  17. package/lib/index.js +17 -13
  18. package/lib/utils/useOverlaidPosition.js +6 -4
  19. package/lib-module/Autocomplete/Autocomplete.js +448 -0
  20. package/lib-module/Autocomplete/Loading.js +36 -0
  21. package/lib-module/Autocomplete/Suggestions.js +66 -0
  22. package/lib-module/Autocomplete/constants.js +4 -0
  23. package/lib-module/Autocomplete/dictionary.js +12 -0
  24. package/lib-module/Autocomplete/index.js +2 -0
  25. package/lib-module/Listbox/GroupControl.js +102 -0
  26. package/lib-module/Listbox/Listbox.js +172 -0
  27. package/lib-module/Listbox/ListboxGroup.js +117 -0
  28. package/lib-module/Listbox/ListboxItem.js +71 -0
  29. package/lib-module/Listbox/ListboxOverlay.js +80 -0
  30. package/lib-module/Listbox/PressableItem.js +0 -2
  31. package/lib-module/Listbox/index.js +2 -2
  32. package/lib-module/TextInput/TextInputBase.js +2 -0
  33. package/lib-module/index.js +2 -1
  34. package/lib-module/utils/useOverlaidPosition.js +5 -4
  35. package/package.json +4 -2
  36. package/src/Autocomplete/Autocomplete.jsx +411 -0
  37. package/src/Autocomplete/Loading.jsx +18 -0
  38. package/src/Autocomplete/Suggestions.jsx +54 -0
  39. package/src/Autocomplete/constants.js +4 -0
  40. package/src/Autocomplete/dictionary.js +12 -0
  41. package/src/Autocomplete/index.js +3 -0
  42. package/src/Listbox/GroupControl.jsx +93 -0
  43. package/src/Listbox/Listbox.jsx +165 -0
  44. package/src/Listbox/ListboxGroup.jsx +120 -0
  45. package/src/Listbox/ListboxItem.jsx +76 -0
  46. package/src/Listbox/ListboxOverlay.jsx +82 -0
  47. package/src/Listbox/PressableItem.jsx +0 -2
  48. package/src/Listbox/index.js +3 -2
  49. package/src/TextInput/TextInputBase.jsx +2 -0
  50. package/src/index.js +2 -1
  51. package/src/utils/useOverlaidPosition.js +6 -5
@@ -0,0 +1,4 @@
1
+ export const DEFAULT_MIN_TO_SUGGESTION = 1;
2
+ export const DEFAULT_MAX_SUGGESTIONS = 5;
3
+ export const INPUT_LEFT_PADDING = 16;
4
+ export const MIN_LISTBOX_WIDTH = 288;
@@ -0,0 +1,12 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ import Autocomplete from './Autocomplete';
2
+ export default Autocomplete;
@@ -0,0 +1,102 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import Text from "react-native-web/dist/exports/Text";
6
+ import { useThemeTokens } from '../ThemeProvider';
7
+ import Icon from '../Icon';
8
+ import Spacer from '../Spacer';
9
+ import { useListboxContext } from './ListboxContext';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ const styles = StyleSheet.create({
13
+ controlWrapper: {
14
+ width: '100%',
15
+ flex: 1,
16
+ alignItems: 'center',
17
+ flexDirection: 'row',
18
+ justifyContent: 'space-between',
19
+ boxSizing: 'border-box'
20
+ }
21
+ });
22
+
23
+ const GroupControl = _ref => {
24
+ let {
25
+ expanded,
26
+ pressed,
27
+ hover,
28
+ focus,
29
+ label,
30
+ id
31
+ } = _ref;
32
+ const {
33
+ selectedId,
34
+ setSelectedId
35
+ } = useListboxContext();
36
+ const tokens = useThemeTokens('Listbox', {}, {}, {
37
+ expanded,
38
+ pressed,
39
+ hover,
40
+ current: selectedId === id && id !== undefined,
41
+ focus
42
+ });
43
+ const {
44
+ groupFontName,
45
+ groupFontWeight,
46
+ groupFontSize,
47
+ groupColor,
48
+ groupBackgroundColor,
49
+ groupBorderColor,
50
+ groupBorderWidth,
51
+ groupBorderRadius,
52
+ groupPaddingLeft,
53
+ groupPaddingRight,
54
+ groupPaddingTop,
55
+ groupPaddingBottom,
56
+ itemTextDecoration,
57
+ itemOutline,
58
+ groupHeight
59
+ } = tokens;
60
+ return /*#__PURE__*/_jsxs(View, {
61
+ onPress: () => setSelectedId(id),
62
+ style: [styles.controlWrapper, {
63
+ fontFamily: `${groupFontName}${groupFontWeight}normal`,
64
+ fontSize: groupFontSize,
65
+ color: groupColor,
66
+ textDecoration: itemTextDecoration,
67
+ backgroundColor: groupBackgroundColor,
68
+ outline: itemOutline,
69
+ height: groupHeight,
70
+ border: `${groupBorderWidth}px solid ${groupBorderColor}`,
71
+ borderRadius: groupBorderRadius,
72
+ paddingLeft: groupPaddingLeft - groupBorderWidth,
73
+ paddingRight: groupPaddingRight - groupBorderWidth,
74
+ paddingTop: groupPaddingTop - groupBorderWidth,
75
+ paddingBottom: groupPaddingBottom - groupBorderWidth
76
+ }],
77
+ children: [/*#__PURE__*/_jsx(Text, {
78
+ children: label
79
+ }), /*#__PURE__*/_jsx(Spacer, {
80
+ space: 1,
81
+ direction: "row"
82
+ }), /*#__PURE__*/_jsx(Icon, {
83
+ icon: tokens.groupIcon,
84
+ tokens: {
85
+ color: tokens.groupColor
86
+ },
87
+ variant: {
88
+ size: 'micro'
89
+ }
90
+ })]
91
+ });
92
+ };
93
+
94
+ GroupControl.propTypes = {
95
+ id: PropTypes.string,
96
+ expanded: PropTypes.bool,
97
+ pressed: PropTypes.bool,
98
+ hover: PropTypes.bool,
99
+ focus: PropTypes.bool,
100
+ label: PropTypes.string
101
+ };
102
+ export default GroupControl;
@@ -0,0 +1,172 @@
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import View from "react-native-web/dist/exports/View";
4
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
5
+ import Platform from "react-native-web/dist/exports/Platform";
6
+ import { useThemeTokens } from '../ThemeProvider';
7
+ import { withLinkRouter, getTokensPropType } from '../utils';
8
+ import ExpandCollapse from '../ExpandCollapse';
9
+ import ListboxGroup from './ListboxGroup';
10
+ import ListboxItem from './ListboxItem';
11
+ import { ListboxContext } from './ListboxContext';
12
+ import DropdownOverlay from './ListboxOverlay';
13
+ import { createElement as _createElement } from "react";
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ const styles = StyleSheet.create({
16
+ list: {
17
+ padding: 0,
18
+ margin: 0
19
+ }
20
+ });
21
+
22
+ const getInitialOpen = (items, selectedId) => items.filter(item => item.items && item.items.some(nestedItem => (nestedItem.id ?? nestedItem.label) === selectedId)).map(item => item.id ?? item.label);
23
+
24
+ const Listbox = _ref => {
25
+ let {
26
+ items = [],
27
+ firstItemRef = null,
28
+ // focus will be moved to this one once within the menu
29
+ parentRef = null,
30
+ // to return focus to after leaving the last menu item
31
+ selectedId: defaultSelectedId,
32
+ LinkRouter,
33
+ itemRouterProps,
34
+ onClose,
35
+ variant,
36
+ tokens
37
+ } = _ref;
38
+ const initialOpen = getInitialOpen(items, defaultSelectedId);
39
+ const [selectedId, setSelectedId] = useState(defaultSelectedId);
40
+ const {
41
+ minHeight,
42
+ minWidth
43
+ } = useThemeTokens('Listbox', variant, tokens); // We need to keep track of each item's ref in order to be able to
44
+ // focus on a specific item via keyboard navigation
45
+
46
+ const itemRefs = useRef([]);
47
+ if (firstItemRef !== null && firstItemRef !== void 0 && firstItemRef.current) itemRefs.current[0] = firstItemRef.current;
48
+ const [focusedIndex, setFocusedIndex] = useState(0);
49
+ const handleKeydown = useCallback(event => {
50
+ const nextItemRef = itemRefs.current[focusedIndex + 1];
51
+ const prevItemRef = itemRefs.current[focusedIndex - 1];
52
+
53
+ if (event.key === 'ArrowUp' || event.shiftKey && event.key === 'Tab') {
54
+ var _parentRef$current;
55
+
56
+ // Move the focus to the previous item or to the parent one if on the first
57
+ if (prevItemRef) {
58
+ event.preventDefault();
59
+ prevItemRef.focus();
60
+ } else if (parentRef) (_parentRef$current = parentRef.current) === null || _parentRef$current === void 0 ? void 0 : _parentRef$current.focus();
61
+
62
+ setFocusedIndex(focusedIndex - 1);
63
+ } else if ((event.key === 'ArrowDown' || event.key === 'Tab') && nextItemRef) {
64
+ event.preventDefault();
65
+ setFocusedIndex(focusedIndex + 1);
66
+ nextItemRef.focus();
67
+ } else if (event.key === 'Escape') {
68
+ var _parentRef$current2, _parentRef$current3;
69
+
70
+ // Close the dropdown
71
+ 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
72
+
73
+ parentRef === null || parentRef === void 0 ? void 0 : (_parentRef$current3 = parentRef.current) === null || _parentRef$current3 === void 0 ? void 0 : _parentRef$current3.focus();
74
+ if (onClose) onClose(event);
75
+ }
76
+ }, [focusedIndex, onClose, parentRef]); // Add listeners for mouse clicks outside and for key presses
77
+
78
+ useEffect(() => {
79
+ if (Platform.OS === 'web') {
80
+ window.addEventListener('click', onClose);
81
+ window.addEventListener('keydown', handleKeydown);
82
+ window.addEventListener('touchstart', onClose);
83
+ return () => {
84
+ window.removeEventListener('click', onClose);
85
+ window.removeEventListener('keydown', handleKeydown);
86
+ window.removeEventListener('touchstart', onClose);
87
+ };
88
+ }
89
+
90
+ return () => {};
91
+ }, [onClose, handleKeydown]);
92
+ return /*#__PURE__*/_jsx(ListboxContext.Provider, {
93
+ value: {
94
+ selectedId,
95
+ setSelectedId
96
+ },
97
+ children: /*#__PURE__*/_jsx(ExpandCollapse, {
98
+ initialOpen: initialOpen,
99
+ maxOpen: 1,
100
+ children: expandProps => /*#__PURE__*/_jsx(View, {
101
+ style: [styles.list, {
102
+ minHeight,
103
+ minWidth
104
+ }],
105
+ role: "listbox",
106
+ children: items.map((item, index) => {
107
+ const {
108
+ id,
109
+ label,
110
+ items: nestedItems
111
+ } = item;
112
+ const itemId = id ?? label; // Give the list of refs.
113
+
114
+ const itemRef = ref => {
115
+ itemRefs.current[index] = ref;
116
+ return ref;
117
+ };
118
+
119
+ return nestedItems ? /*#__PURE__*/_createElement(ListboxGroup, { ...item,
120
+ expandProps: expandProps,
121
+ LinkRouter: LinkRouter,
122
+ itemRouterProps: itemRouterProps,
123
+ prevItemRef: itemRefs.current[index - 1] ?? null,
124
+ nextItemRef: itemRefs.current[index + 1] ?? null,
125
+ ref: index === 0 ? firstItemRef : itemRef,
126
+ key: itemId
127
+ }) : /*#__PURE__*/_createElement(ListboxItem, { ...item,
128
+ key: itemId,
129
+ id: itemId,
130
+ LinkRouter: LinkRouter,
131
+ itemRouterProps: itemRouterProps,
132
+ prevItemRef: itemRefs.current[index - 1] ?? null,
133
+ nextItemRef: itemRefs.current[index + 1] ?? null,
134
+ ref: index === 0 ? firstItemRef : itemRef
135
+ });
136
+ })
137
+ })
138
+ })
139
+ });
140
+ };
141
+
142
+ Listbox.propTypes = { ...withLinkRouter.propTypes,
143
+
144
+ /**
145
+ * Focus will be moved to the item with this ref once within the menu.
146
+ */
147
+ firstItemRef: PropTypes.object,
148
+
149
+ /**
150
+ * Focus will be returned to the dropdown control with this ref after leaving
151
+ * the last menu item.
152
+ */
153
+ parentRef: PropTypes.object,
154
+
155
+ /**
156
+ * `Listbox` items
157
+ */
158
+ items: PropTypes.array,
159
+
160
+ /**
161
+ * To select an item by default
162
+ */
163
+ selectedId: PropTypes.string,
164
+
165
+ /**
166
+ * onClose event
167
+ */
168
+ onClose: PropTypes.func,
169
+ tokens: getTokensPropType('Listbox')
170
+ };
171
+ Listbox.Overlay = DropdownOverlay;
172
+ export default Listbox;
@@ -0,0 +1,117 @@
1
+ /* eslint-disable react-native-a11y/has-valid-accessibility-role */
2
+ import React, { forwardRef } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import View from "react-native-web/dist/exports/View";
5
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
6
+ import { withLinkRouter } from '../utils';
7
+ import ExpandCollapse from '../ExpandCollapse';
8
+ import ListboxItem from './ListboxItem';
9
+ import { useListboxContext } from './ListboxContext';
10
+ import GroupControl from './GroupControl';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const styles = StyleSheet.create({
13
+ groupWrapper: {
14
+ margin: 0,
15
+ padding: 0,
16
+ overflow: 'hidden'
17
+ },
18
+ list: {
19
+ margin: 0,
20
+ padding: 0
21
+ }
22
+ });
23
+ const ListboxGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
24
+ let {
25
+ id,
26
+ label,
27
+ items,
28
+ LinkRouter,
29
+ linkRouterProps,
30
+ expandProps,
31
+ onLastItemBlur,
32
+ nextItemRef,
33
+ prevItemRef
34
+ } = _ref;
35
+ const {
36
+ selectedId
37
+ } = useListboxContext(); // TODO: implement keyboard navigation via refs for grouped items separately here
38
+
39
+ return /*#__PURE__*/_jsx(View, {
40
+ id: "test",
41
+ style: styles.groupWrapper,
42
+ accessibilityRole: "listitem",
43
+ children: /*#__PURE__*/_jsx(ExpandCollapse.Panel, {
44
+ panelId: id ?? label,
45
+ controlTokens: {
46
+ icon: null,
47
+ paddingLeft: 0,
48
+ paddingRight: 0,
49
+ paddingTop: 0,
50
+ paddingBottom: 0,
51
+ backgroundColor: 'transparent',
52
+ borderColor: 'transparent',
53
+ textLine: 'none',
54
+ borderWidth: 0
55
+ } // TODO refactor
56
+ // eslint-disable-next-line react/no-unstable-nested-components
57
+ ,
58
+ control: controlProps => /*#__PURE__*/_jsx(GroupControl, {
59
+ id: id ?? label,
60
+ ...controlProps,
61
+ label: label
62
+ }),
63
+ ...expandProps,
64
+ tokens: {
65
+ contentPaddingLeft: 0,
66
+ contentPaddingRight: 0,
67
+ contentPaddingTop: 0,
68
+ contentPaddingBottom: 0,
69
+ borderColor: 'transparent',
70
+ borderRadius: 0,
71
+ borderWidth: 0,
72
+ marginBottom: 0
73
+ },
74
+ controlRef: ref,
75
+ children: /*#__PURE__*/_jsx(View, {
76
+ style: styles.list,
77
+ children: items.map((item, index) => {
78
+ return /*#__PURE__*/_jsx(ListboxItem, {
79
+ id: item.id ?? item.label,
80
+ ...item,
81
+ selected: item.id && item.id === selectedId || item.label && item.label === selectedId,
82
+ isChild: true,
83
+ LinkRouter: LinkRouter,
84
+ linkRouterProps: linkRouterProps,
85
+ ...(index === 0 && {
86
+ prevItemRef
87
+ }),
88
+ ...(index === items.length - 1 && {
89
+ nextItemRef
90
+ }),
91
+ ...(index === items.length - 1 && {
92
+ onBlur: onLastItemBlur
93
+ })
94
+ }, item.label);
95
+ })
96
+ })
97
+ })
98
+ });
99
+ });
100
+ ListboxGroup.displayName = 'ListboxGroup';
101
+ ListboxGroup.propTypes = { ...withLinkRouter.propTypes,
102
+ label: PropTypes.string,
103
+ items: PropTypes.arrayOf(PropTypes.shape({
104
+ href: PropTypes.string,
105
+ label: PropTypes.string,
106
+ current: PropTypes.bool
107
+ })),
108
+ expandProps: PropTypes.object,
109
+ nextItemRef: PropTypes.object,
110
+ prevItemRef: PropTypes.object,
111
+
112
+ /**
113
+ * Use this callback to redirect the focus after it leaves the last item of the group.
114
+ */
115
+ onLastItemBlur: PropTypes.func
116
+ };
117
+ export default ListboxGroup;
@@ -0,0 +1,71 @@
1
+ /* eslint-disable react/require-default-props */
2
+ import React, { forwardRef } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import View from "react-native-web/dist/exports/View";
5
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
6
+ import { selectSystemProps, withLinkRouter, htmlAttrs } from '../utils';
7
+ import PressableItem from './PressableItem';
8
+ import { useThemeTokensCallback } from '../ThemeProvider';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const [selectProps, selectedSystemPropTypes] = selectSystemProps([htmlAttrs]);
11
+ const styles = StyleSheet.create({
12
+ itemContainer: {
13
+ display: 'flex',
14
+ margin: 0
15
+ },
16
+ childContainer: {
17
+ paddingLeft: 16
18
+ }
19
+ });
20
+ const ListboxItem = /*#__PURE__*/forwardRef((_ref, ref) => {
21
+ let {
22
+ href,
23
+ label,
24
+ isChild = false,
25
+ onBlur,
26
+ nextItemRef,
27
+ prevItemRef,
28
+ tokens,
29
+ variant = {},
30
+ LinkRouter,
31
+ linkRouterProps,
32
+ id,
33
+ onPress = () => {},
34
+ ...rest
35
+ } = _ref;
36
+ const selectedProps = selectProps({
37
+ href,
38
+ ...rest
39
+ });
40
+ const getTokens = useThemeTokensCallback('Listbox', tokens, variant, {
41
+ isChild
42
+ });
43
+ return /*#__PURE__*/_jsx(View, {
44
+ style: [styles.itemContainer, isChild && styles.childContainer],
45
+ role: "option",
46
+ children: /*#__PURE__*/_jsx(PressableItem, {
47
+ href: href,
48
+ isChild: isChild,
49
+ onPress: onPress,
50
+ onBlur: onBlur,
51
+ nextItemRef: nextItemRef,
52
+ prevItemRef: prevItemRef,
53
+ ref: ref,
54
+ tokens: getTokens,
55
+ selectedProps: selectedProps,
56
+ id: id,
57
+ children: label
58
+ })
59
+ });
60
+ });
61
+ ListboxItem.displayName = 'ListboxItem';
62
+ ListboxItem.propTypes = { ...selectedSystemPropTypes,
63
+ ...withLinkRouter.propTypes,
64
+ href: PropTypes.string,
65
+ isChild: PropTypes.bool,
66
+ label: PropTypes.node.isRequired,
67
+ nextItemRef: PropTypes.object,
68
+ prevItemRef: PropTypes.object,
69
+ onPress: PropTypes.func
70
+ };
71
+ export default withLinkRouter(ListboxItem);
@@ -0,0 +1,80 @@
1
+ /* eslint-disable react/require-default-props */
2
+ import React, { forwardRef } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import View from "react-native-web/dist/exports/View";
5
+ import StyleSheet from "react-native-web/dist/exports/StyleSheet";
6
+ import Platform from "react-native-web/dist/exports/Platform";
7
+ import { Portal } from '@gorhom/portal';
8
+ import { useThemeTokens } from '../ThemeProvider';
9
+ import Card from '../Card';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ const staticStyles = StyleSheet.create({
12
+ positioner: {
13
+ flex: 1,
14
+ // Grow to maxWidth when possible, shrink when not possible
15
+ position: 'absolute',
16
+ zIndex: 1000000000000000 // Position on top of all the other overlays, including backdrops and modals
17
+
18
+ },
19
+ hidden: {
20
+ // Use opacity not visibility to hide the dropdown during positioning
21
+ // so on web, children may be focused from the first render
22
+ opacity: 0
23
+ }
24
+ });
25
+ const paddingVertical = 0;
26
+ const paddingHorizontal = 0;
27
+ const DropdownOverlay = /*#__PURE__*/forwardRef((_ref, ref) => {
28
+ let {
29
+ children,
30
+ isReady = false,
31
+ overlaidPosition,
32
+ maxWidth,
33
+ minWidth,
34
+ onLayout
35
+ } = _ref;
36
+ const systemTokens = useThemeTokens('Listbox', {}, {});
37
+ return /*#__PURE__*/_jsx(View, {
38
+ ref: ref,
39
+ onLayout: onLayout,
40
+ style: [overlaidPosition, {
41
+ maxWidth,
42
+ minWidth
43
+ }, staticStyles.positioner, !isReady && staticStyles.hidden],
44
+ children: /*#__PURE__*/_jsx(Card, {
45
+ tokens: {
46
+ shadow: systemTokens.shadow,
47
+ paddingBottom: paddingVertical,
48
+ paddingTop: paddingVertical,
49
+ paddingLeft: paddingHorizontal,
50
+ paddingRight: paddingHorizontal
51
+ },
52
+ children: children
53
+ })
54
+ });
55
+ });
56
+
57
+ const withPortal = Overlay => {
58
+ // eslint-disable-next-line react/display-name, react/no-multi-comp
59
+ return props => {
60
+ return /*#__PURE__*/_jsx(Portal, {
61
+ children: /*#__PURE__*/_jsx(Overlay, { ...props
62
+ })
63
+ });
64
+ };
65
+ };
66
+
67
+ DropdownOverlay.displayName = 'DropdownOverlay';
68
+ DropdownOverlay.propTypes = {
69
+ children: PropTypes.node.isRequired,
70
+ isReady: PropTypes.bool,
71
+ overlaidPosition: PropTypes.shape({
72
+ top: PropTypes.number,
73
+ left: PropTypes.number,
74
+ width: PropTypes.number
75
+ }),
76
+ maxWidth: PropTypes.number,
77
+ minWidth: PropTypes.number,
78
+ onLayout: PropTypes.func
79
+ };
80
+ export default Platform.OS === 'web' ? withPortal(DropdownOverlay) : DropdownOverlay;
@@ -21,7 +21,6 @@ const getItemStyles = _ref => {
21
21
  itemPaddingRight,
22
22
  itemBackgroundColor,
23
23
  itemColor,
24
- itemDisplay,
25
24
  itemOutline,
26
25
  itemTextDecoration,
27
26
  itemBorderLeftColor,
@@ -43,7 +42,6 @@ const getItemStyles = _ref => {
43
42
  width: '100%',
44
43
  backgroundColor: itemBackgroundColor,
45
44
  color: itemColor,
46
- display: itemDisplay,
47
45
  outline: itemOutline,
48
46
  textDecoration: itemTextDecoration,
49
47
  borderLeft: `${itemBorderLeftWidth}px solid ${itemBorderLeftColor}`,
@@ -1,2 +1,2 @@
1
- export * from './ListboxContext';
2
- export { default as PressableItem } from './PressableItem';
1
+ import Listbox from './Listbox';
2
+ export default Listbox;
@@ -347,6 +347,8 @@ export default TextInputBase;
347
347
  const staticStyles = StyleSheet.create({
348
348
  buttonsContainer: {
349
349
  position: 'absolute',
350
+ flexDirection: 'row',
351
+ alignItems: 'center',
350
352
  right: 0,
351
353
  top: 0,
352
354
  bottom: 0,
@@ -1,10 +1,11 @@
1
1
  export { default as A11yText } from './A11yText';
2
2
  export { default as ActivityIndicator } from './ActivityIndicator';
3
+ export { default as Autocomplete } from './Autocomplete';
3
4
  export { default as Box } from './Box';
4
5
  export * from './Button';
5
6
  export { default as Card, PressableCardBase } from './Card';
6
7
  export * from './Carousel';
7
- export * from './Listbox';
8
+ export { default as Listbox } from './Listbox';
8
9
  export { default as Checkbox } from './Checkbox';
9
10
  export * from './Checkbox';
10
11
  export { default as Divider } from './Divider';
@@ -1,5 +1,6 @@
1
1
  import { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import Dimensions from "react-native-web/dist/exports/Dimensions";
3
+ import Platform from "react-native-web/dist/exports/Platform";
3
4
 
4
5
  const adjustHorizontalToFit = (initialOffset, windowWidth, sourceWidth) => {
5
6
  const offset = Math.max(0, initialOffset);
@@ -172,8 +173,8 @@ const useOverlaidPosition = _ref3 => {
172
173
  let {
173
174
  window
174
175
  } = _ref5;
175
- (_sourceRef$current = sourceRef.current) === null || _sourceRef$current === void 0 ? void 0 : _sourceRef$current.measureInWindow((x, y, width, height) => {
176
- // Could add a debouncer here if there's too many rerenders during gradual resizes
176
+ const measurementFunction = Platform.OS === 'web' ? 'measureInWindow' : 'measure';
177
+ (_sourceRef$current = sourceRef.current) === null || _sourceRef$current === void 0 ? void 0 : _sourceRef$current[measurementFunction]((x, y, width, height) => {
177
178
  setWindowDimensions(window);
178
179
  setSourceLayout({
179
180
  x,
@@ -192,9 +193,9 @@ const useOverlaidPosition = _ref3 => {
192
193
  if (typeof ((_subscription = subscription) === null || _subscription === void 0 ? void 0 : _subscription.remove) === 'function') {
193
194
  // React Native >=0.65.0
194
195
  subscription.remove();
195
- } else if (typeof Dimensions.removeEventListener === 'function') {
196
+ } else if (typeof Dimensions.remove === 'function') {
196
197
  // React Native <0.65.0
197
- Dimensions.removeEventListener('change', handleDimensionsChange);
198
+ Dimensions.remove('change', handleDimensionsChange);
198
199
  }
199
200
 
200
201
  setSourceLayout(null);
package/package.json CHANGED
@@ -15,9 +15,11 @@
15
15
  "airbnb-prop-types": "^2.16.0",
16
16
  "lodash.debounce": "^4.0.8",
17
17
  "lodash.merge": "^4.6.2",
18
+ "lodash.throttle": "^4.1.1",
18
19
  "prop-types": "^15.7.2",
19
20
  "react-native-picker-select": "^8.0.4",
20
- "semver": "7.5.2"
21
+ "semver": "7.5.2",
22
+ "string.prototype.matchall": "^4.0.9"
21
23
  },
22
24
  "description": "Base components",
23
25
  "devDependencies": {
@@ -72,5 +74,5 @@
72
74
  "standard-engine": {
73
75
  "skip": true
74
76
  },
75
- "version": "1.60.0"
77
+ "version": "1.61.0"
76
78
  }