baseui 10.4.0 → 10.7.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.
Files changed (195) hide show
  1. package/app-nav-bar/user-menu.js +1 -0
  2. package/app-nav-bar/user-menu.js.flow +1 -0
  3. package/button/styled-components.js +1 -1
  4. package/button/styled-components.js.flow +4 -1
  5. package/card/styled-components.js +0 -1
  6. package/card/styled-components.js.flow +0 -1
  7. package/combobox/combobox.js +5 -1
  8. package/combobox/combobox.js.flow +4 -0
  9. package/combobox/index.d.ts +6 -3
  10. package/data-table/column-datetime.js +2 -0
  11. package/data-table/column-datetime.js.flow +2 -0
  12. package/datepicker/calendar-header.js +255 -109
  13. package/datepicker/calendar-header.js.flow +282 -145
  14. package/datepicker/calendar.js +6 -1
  15. package/datepicker/calendar.js.flow +5 -1
  16. package/datepicker/constants.js +9 -2
  17. package/datepicker/constants.js.flow +7 -0
  18. package/datepicker/datepicker.js +135 -73
  19. package/datepicker/datepicker.js.flow +161 -62
  20. package/datepicker/day.js +2 -0
  21. package/datepicker/day.js.flow +2 -0
  22. package/datepicker/index.d.ts +8 -0
  23. package/datepicker/month.js +4 -0
  24. package/datepicker/month.js.flow +3 -0
  25. package/datepicker/styled-components.js +116 -56
  26. package/datepicker/styled-components.js.flow +101 -36
  27. package/datepicker/types.js.flow +18 -1
  28. package/datepicker/utils/calendar-header-helpers.js +51 -0
  29. package/datepicker/utils/calendar-header-helpers.js.flow +53 -0
  30. package/datepicker/utils/date-helpers.js +1 -1
  31. package/datepicker/utils/date-helpers.js.flow +1 -1
  32. package/datepicker/week.js +1 -0
  33. package/datepicker/week.js.flow +1 -0
  34. package/dnd-list/index.js.flow +2 -1
  35. package/dnd-list/list.js +1 -2
  36. package/dnd-list/list.js.flow +1 -1
  37. package/dnd-list/styled-components.js +1 -1
  38. package/dnd-list/styled-components.js.flow +1 -0
  39. package/drawer/drawer.js +2 -1
  40. package/drawer/drawer.js.flow +1 -1
  41. package/es/app-nav-bar/user-menu.js +1 -0
  42. package/es/button/styled-components.js +1 -1
  43. package/es/card/styled-components.js +0 -1
  44. package/es/combobox/combobox.js +5 -1
  45. package/es/data-table/column-datetime.js +2 -0
  46. package/es/datepicker/calendar-header.js +204 -93
  47. package/es/datepicker/calendar.js +7 -2
  48. package/es/datepicker/constants.js +6 -1
  49. package/es/datepicker/datepicker.js +70 -42
  50. package/es/datepicker/day.js +2 -0
  51. package/es/datepicker/month.js +3 -0
  52. package/es/datepicker/styled-components.js +98 -37
  53. package/es/datepicker/types.js +1 -1
  54. package/es/datepicker/utils/calendar-header-helpers.js +34 -0
  55. package/es/datepicker/utils/date-helpers.js +1 -1
  56. package/es/datepicker/week.js +1 -0
  57. package/es/dnd-list/index.js +2 -1
  58. package/es/dnd-list/list.js +1 -2
  59. package/es/dnd-list/styled-components.js +1 -0
  60. package/es/drawer/drawer.js +2 -1
  61. package/es/helper/helper.js +1 -0
  62. package/es/layer/layer.js +8 -0
  63. package/es/map-marker/constants.js +69 -0
  64. package/es/map-marker/fixed-marker.js +98 -0
  65. package/es/map-marker/floating-marker.js +65 -0
  66. package/es/map-marker/index.js +9 -0
  67. package/es/map-marker/pin-head.js +108 -0
  68. package/es/map-marker/styled-components.js +156 -0
  69. package/es/map-marker/types.js +8 -0
  70. package/es/menu/maybe-child-menu.js +1 -0
  71. package/es/popover/popover.js +6 -5
  72. package/es/popover/stateful-container.js +8 -2
  73. package/es/rating/emoticon-rating.js +3 -1
  74. package/es/rating/star-rating.js +3 -1
  75. package/es/select/select-component.js +20 -5
  76. package/es/select/styled-components.js +34 -4
  77. package/es/snackbar/snackbar-context.js +16 -4
  78. package/es/table-semantic/styled-components.js +6 -4
  79. package/es/table-semantic/table-builder.js +3 -0
  80. package/es/themes/dark-theme/color-component-tokens.js +1 -1
  81. package/es/themes/light-theme/color-component-tokens.js +9 -9
  82. package/es/themes/shared/lighting.js +5 -1
  83. package/es/timepicker/timepicker.js +16 -11
  84. package/es/tooltip/styled-components.js +8 -0
  85. package/es/tooltip/tooltip.js +1 -0
  86. package/esm/app-nav-bar/user-menu.js +1 -0
  87. package/esm/button/styled-components.js +1 -1
  88. package/esm/card/styled-components.js +0 -1
  89. package/esm/combobox/combobox.js +5 -1
  90. package/esm/data-table/column-datetime.js +2 -0
  91. package/esm/datepicker/calendar-header.js +255 -110
  92. package/esm/datepicker/calendar.js +7 -2
  93. package/esm/datepicker/constants.js +6 -1
  94. package/esm/datepicker/datepicker.js +136 -74
  95. package/esm/datepicker/day.js +2 -0
  96. package/esm/datepicker/month.js +3 -0
  97. package/esm/datepicker/styled-components.js +112 -55
  98. package/esm/datepicker/types.js +1 -1
  99. package/esm/datepicker/utils/calendar-header-helpers.js +45 -0
  100. package/esm/datepicker/utils/date-helpers.js +1 -1
  101. package/esm/datepicker/week.js +1 -0
  102. package/esm/dnd-list/index.js +2 -1
  103. package/esm/dnd-list/list.js +1 -2
  104. package/esm/dnd-list/styled-components.js +1 -1
  105. package/esm/drawer/drawer.js +2 -1
  106. package/esm/helper/helper.js +1 -0
  107. package/esm/layer/layer.js +8 -0
  108. package/esm/map-marker/constants.js +62 -0
  109. package/esm/map-marker/fixed-marker.js +137 -0
  110. package/esm/map-marker/floating-marker.js +94 -0
  111. package/esm/map-marker/index.js +9 -0
  112. package/esm/map-marker/pin-head.js +144 -0
  113. package/esm/map-marker/styled-components.js +168 -0
  114. package/esm/map-marker/types.js +8 -0
  115. package/esm/menu/maybe-child-menu.js +1 -0
  116. package/esm/popover/popover.js +6 -5
  117. package/esm/popover/stateful-container.js +8 -2
  118. package/esm/rating/emoticon-rating.js +2 -2
  119. package/esm/rating/star-rating.js +2 -2
  120. package/esm/select/select-component.js +19 -5
  121. package/esm/select/styled-components.js +28 -4
  122. package/esm/snackbar/snackbar-context.js +16 -4
  123. package/esm/table-semantic/styled-components.js +6 -4
  124. package/esm/table-semantic/table-builder.js +3 -0
  125. package/esm/themes/dark-theme/color-component-tokens.js +1 -1
  126. package/esm/themes/light-theme/color-component-tokens.js +9 -9
  127. package/esm/themes/shared/lighting.js +5 -1
  128. package/esm/timepicker/timepicker.js +17 -11
  129. package/esm/tooltip/styled-components.js +8 -0
  130. package/esm/tooltip/tooltip.js +1 -0
  131. package/helper/helper.js +1 -0
  132. package/helper/helper.js.flow +1 -0
  133. package/layer/layer.js +8 -0
  134. package/layer/layer.js.flow +9 -0
  135. package/link/index.d.ts +1 -0
  136. package/map-marker/constants.js +82 -0
  137. package/map-marker/constants.js.flow +74 -0
  138. package/map-marker/fixed-marker.js +152 -0
  139. package/map-marker/fixed-marker.js.flow +137 -0
  140. package/map-marker/floating-marker.js +109 -0
  141. package/map-marker/floating-marker.js.flow +102 -0
  142. package/map-marker/index.d.ts +105 -0
  143. package/map-marker/index.js +55 -0
  144. package/map-marker/index.js.flow +23 -0
  145. package/map-marker/package.json +4 -0
  146. package/map-marker/pin-head.js +159 -0
  147. package/map-marker/pin-head.js.flow +155 -0
  148. package/map-marker/styled-components.js +184 -0
  149. package/map-marker/styled-components.js.flow +177 -0
  150. package/map-marker/types.js +11 -0
  151. package/map-marker/types.js.flow +114 -0
  152. package/menu/index.d.ts +7 -0
  153. package/menu/maybe-child-menu.js +1 -0
  154. package/menu/maybe-child-menu.js.flow +1 -0
  155. package/menu/types.js.flow +12 -0
  156. package/modal/index.d.ts +1 -1
  157. package/modal/types.js.flow +4 -1
  158. package/package.json +5 -3
  159. package/popover/index.d.ts +2 -1
  160. package/popover/popover.js +6 -5
  161. package/popover/popover.js.flow +11 -4
  162. package/popover/stateful-container.js +8 -2
  163. package/popover/stateful-container.js.flow +5 -0
  164. package/popover/types.js.flow +6 -1
  165. package/rating/emoticon-rating.js +2 -2
  166. package/rating/emoticon-rating.js.flow +4 -1
  167. package/rating/star-rating.js +2 -2
  168. package/rating/star-rating.js.flow +4 -1
  169. package/select/select-component.js +19 -5
  170. package/select/select-component.js.flow +19 -5
  171. package/select/styled-components.js +28 -4
  172. package/select/styled-components.js.flow +30 -2
  173. package/select/types.js.flow +9 -0
  174. package/snackbar/index.d.ts +21 -16
  175. package/snackbar/snackbar-context.js +15 -4
  176. package/snackbar/snackbar-context.js.flow +15 -3
  177. package/table-semantic/styled-components.js +6 -4
  178. package/table-semantic/styled-components.js.flow +6 -4
  179. package/table-semantic/table-builder.js +3 -0
  180. package/table-semantic/table-builder.js.flow +3 -0
  181. package/themes/dark-theme/color-component-tokens.js +1 -1
  182. package/themes/dark-theme/color-component-tokens.js.flow +1 -1
  183. package/themes/light-theme/color-component-tokens.js +9 -9
  184. package/themes/light-theme/color-component-tokens.js.flow +9 -9
  185. package/themes/shared/lighting.js +5 -1
  186. package/themes/shared/lighting.js.flow +4 -0
  187. package/themes/types.js.flow +4 -0
  188. package/timepicker/index.d.ts +1 -0
  189. package/timepicker/timepicker.js +17 -11
  190. package/timepicker/timepicker.js.flow +31 -12
  191. package/timepicker/types.js.flow +10 -0
  192. package/tooltip/styled-components.js +8 -0
  193. package/tooltip/styled-components.js.flow +8 -0
  194. package/tooltip/tooltip.js +1 -0
  195. package/tooltip/tooltip.js.flow +6 -1
@@ -0,0 +1,114 @@
1
+ /*
2
+ Copyright (c) Uber Technologies, Inc.
3
+
4
+ This source code is licensed under the MIT license found in the
5
+ LICENSE file in the root directory of this source tree.
6
+ */
7
+ // @flow
8
+ import * as React from 'react';
9
+ import {
10
+ FLOATING_MARKER_ANCHOR_POSITIONS,
11
+ NEEDLE_SIZES,
12
+ PINHEAD_SIZES_SHAPES,
13
+ FLOATING_MARKER_SIZES,
14
+ PINHEAD_TYPES,
15
+ FLOATING_MARKER_ANCHOR_TYPES,
16
+ } from './constants.js';
17
+ import type {OverrideT} from '../helpers/overrides.js';
18
+
19
+ export type PinHeadT = $Values<typeof PINHEAD_TYPES>;
20
+
21
+ export type AnchorPositionsT = $Values<typeof FLOATING_MARKER_ANCHOR_POSITIONS>;
22
+
23
+ export type NeedleSizeT = $Values<typeof NEEDLE_SIZES>;
24
+
25
+ export type PinHeadSizeT = $Values<typeof PINHEAD_SIZES_SHAPES>;
26
+
27
+ export type FloatingMarkerSizeT = $Values<typeof FLOATING_MARKER_SIZES>;
28
+
29
+ /* eslint-disable flowtype/generic-spacing*/
30
+ export type FloatingMarkerAnchorTypeT = $Values<
31
+ typeof FLOATING_MARKER_ANCHOR_TYPES,
32
+ >;
33
+
34
+ export type NeedlePropsT = {
35
+ size: NeedleSizeT,
36
+ background?: string,
37
+ overrides: FixedMarkerOverridesT,
38
+ };
39
+
40
+ export type ItemPropsT = {
41
+ children?: React.Node,
42
+ color?: string,
43
+ size?: number,
44
+ };
45
+
46
+ export type FixedMarkerOverridesT = {
47
+ Root?: OverrideT,
48
+ InnerAnchor?: OverrideT,
49
+ OuterAnchor?: OverrideT,
50
+ PinHead?: OverrideT,
51
+ PinHeadContent?: OverrideT,
52
+ PinHeadContainer?: OverrideT,
53
+ Needle?: OverrideT,
54
+ DragShadow?: OverrideT,
55
+ DragShadowContainer?: OverrideT,
56
+ DragContainer?: OverrideT,
57
+ };
58
+
59
+ export type FixedMarkerPropsT = {
60
+ size?: PinHeadSizeT,
61
+ needle?: NeedleSizeT,
62
+ label?: string,
63
+ startEnhancer?: React.AbstractComponent<{|size: number|}>,
64
+ endEnhancer?: React.AbstractComponent<{|size: number|}>,
65
+ color?: string,
66
+ background?: string,
67
+ dragging?: boolean,
68
+ overrides?: FixedMarkerOverridesT,
69
+ };
70
+
71
+ export type FloatingMarkerOverridesT = {
72
+ Root?: OverrideT,
73
+ InnerAnchor?: OverrideT,
74
+ OuterAnchor?: OverrideT,
75
+ PinHead?: OverrideT,
76
+ PinHeadContent?: OverrideT,
77
+ PinHeadContainer?: OverrideT,
78
+ AnchorContainer?: OverrideT,
79
+ };
80
+
81
+ export type FloatingMarkerPropsT = {
82
+ color?: string,
83
+ background?: string,
84
+ label?: string,
85
+ anchor?: AnchorPositionsT,
86
+ endEnhancer?: React.AbstractComponent<{|size: number|}>,
87
+ startEnhancer?: React.AbstractComponent<{|size: number|}>,
88
+ anchorType?: FloatingMarkerAnchorTypeT,
89
+ size?: FloatingMarkerSizeT,
90
+ overrides?: FloatingMarkerOverridesT,
91
+ };
92
+
93
+ export type PinHeadPropsT = {
94
+ size?: PinHeadSizeT,
95
+ label?: string,
96
+ endEnhancer?: React.AbstractComponent<{|size: number|}>,
97
+ startEnhancer?: React.AbstractComponent<{|size: number|}>,
98
+ color?: string,
99
+ background?: string,
100
+ type?: PinHeadT,
101
+ anchorType?: FloatingMarkerAnchorTypeT,
102
+ overrides?: FloatingMarkerOverridesT | FixedMarkerOverridesT,
103
+ };
104
+
105
+ export type DragShadowPropsT = {
106
+ background: string,
107
+ dragging: boolean,
108
+ height: number,
109
+ overrides: FixedMarkerOverridesT,
110
+ };
111
+
112
+ declare var __DEV__: boolean;
113
+ declare var __NODE__: boolean;
114
+ declare var __BROWSER__: boolean;
package/menu/index.d.ts CHANGED
@@ -123,6 +123,7 @@ export interface OptionListProps extends BaseMenuPropsT {
123
123
  item: any;
124
124
  getItemLabel: (item: any) => React.ReactNode;
125
125
  getChildMenu?: (item: any) => React.ReactNode;
126
+ onMouseDown?: (event: MouseEvent) => any;
126
127
  onMouseEnter?: (event: MouseEvent) => any;
127
128
  size?: OPTION_LIST_SIZE[keyof OPTION_LIST_SIZE];
128
129
  overrides?: {
@@ -133,6 +134,12 @@ export interface OptionListProps extends BaseMenuPropsT {
133
134
  resetMenu?: () => void;
134
135
  $isHighlighted?: boolean;
135
136
  $isFocused?: boolean;
137
+ renderAll?: boolean;
138
+ $disabled?: boolean;
139
+ 'aria-disabled'?: boolean;
140
+ 'aria-selected'?: boolean;
141
+ id?: string;
142
+ role?: string;
136
143
  }
137
144
  export const OptionList: React.FC<OptionListProps>;
138
145
 
@@ -55,6 +55,7 @@ function MaybeChildMenu(props) {
55
55
  return /*#__PURE__*/React.createElement(_nestedMenus.NestedMenuContext.Consumer, null, function (ctx) {
56
56
  return /*#__PURE__*/React.createElement(PopoverOverride, _extends({
57
57
  focusLock: false,
58
+ autoFocus: false,
58
59
  isOpen: props.isOpen,
59
60
  renderAll: props.renderAll,
60
61
  content: ChildMenu,
@@ -48,6 +48,7 @@ export default function MaybeChildMenu(props: PropsT) {
48
48
  return (
49
49
  <PopoverOverride
50
50
  focusLock={false}
51
+ autoFocus={false}
51
52
  isOpen={props.isOpen}
52
53
  renderAll={props.renderAll}
53
54
  content={ChildMenu}
@@ -234,6 +234,8 @@ export type OptionListPropsT = {
234
234
  getChildMenu?: (item: ItemT) => React.Node,
235
235
  onClick?: (event: MouseEvent) => mixed,
236
236
  /** Callback used to change highlighted index in stateful menu. */
237
+ onMouseDown?: (event: MouseEvent) => mixed,
238
+ /** Callback used to change highlighted index in stateful menu. */
237
239
  onMouseEnter?: (event: MouseEvent) => mixed,
238
240
  /** Renders UI in defined scale. */
239
241
  size?: $Keys<typeof OPTION_LIST_SIZE>,
@@ -251,6 +253,16 @@ export type OptionListPropsT = {
251
253
  $isFocused?: boolean,
252
254
  /** Renders all menu content for SEO purposes regardless of menu state */
253
255
  renderAll?: boolean,
256
+ /** Is the item disabled */
257
+ $disabled?: boolean,
258
+ /** Is the item disabled */
259
+ 'aria-disabled'?: boolean,
260
+ /** Is the item selected */
261
+ 'aria-selected'?: boolean,
262
+ /** Id of the item */
263
+ id?: string,
264
+ /** Accessibility role of the item */
265
+ role?: string,
254
266
  };
255
267
 
256
268
  export type OptionProfilePropsT = {
package/modal/index.d.ts CHANGED
@@ -47,7 +47,7 @@ export interface ModalProps {
47
47
  autofocus?: boolean;
48
48
  autoFocus?: boolean;
49
49
  focusLock?: boolean;
50
- returnFocus?: boolean | FocusOptions;
50
+ returnFocus?: boolean | FocusOptions | ((returnTo: Element) => boolean | FocusOptions);
51
51
  children?: React.ReactNode;
52
52
  closeable?: boolean;
53
53
  isOpen?: boolean;
@@ -48,7 +48,10 @@ export type ModalPropsT = {
48
48
  * Optionally, can pass focus options instead of `true` to control the focus
49
49
  * more precisely (ie. `{ preventScroll: true }`)
50
50
  */
51
- returnFocus?: boolean | FocusOptions,
51
+ returnFocus?:
52
+ | boolean
53
+ | FocusOptions
54
+ | ((returnTo: Element) => boolean | FocusOptions),
52
55
  /** Modal content. The children-as-function API may be preferable
53
56
  * for performance reasons (wont render until opened) */
54
57
  children?: React.Node | (() => React.Node),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baseui",
3
- "version": "10.4.0",
3
+ "version": "10.7.1",
4
4
  "description": "A React Component library implementing the Base design language",
5
5
  "keywords": [
6
6
  "react",
@@ -81,7 +81,7 @@
81
81
  "@commitlint/config-conventional": "^8.0.0",
82
82
  "@date-io/luxon": "^2.7.0",
83
83
  "@date-io/moment": "^2.7.0",
84
- "@ladle/react": "^0.2.0",
84
+ "@ladle/react": "^0.3.0",
85
85
  "@mdx-js/tag": "^0.20.0",
86
86
  "@octokit/rest": "^16.33.1",
87
87
  "@svgr/cli": "^4.3.2",
@@ -170,6 +170,7 @@
170
170
  "react-dom": "^16.9.0",
171
171
  "react-hook-form": "^7.9.0",
172
172
  "react-icons": "^3.8.0",
173
+ "react-map-gl": "^6.1.17",
173
174
  "react-markdown": "^4.0.3",
174
175
  "react-twitter-embed": "^2.0.8",
175
176
  "react-view": "^2.3.3",
@@ -196,10 +197,11 @@
196
197
  "glob": "^7.1.6",
197
198
  "just-extend": "^4.0.2",
198
199
  "memoize-one": "^5.1.1",
200
+ "mockdate": "^3.0.5",
199
201
  "polished": "^3.2.0",
200
202
  "popper.js": "^1.16.0",
201
203
  "react-dropzone": "^9.0.0",
202
- "react-focus-lock": "^2.2.1",
204
+ "react-focus-lock": "^2.7.1",
203
205
  "react-input-mask": "^2.0.4",
204
206
  "react-is": "^16.8.6",
205
207
  "react-movable": "^2.5.4",
@@ -96,7 +96,8 @@ export interface BasePopoverProps {
96
96
  accessibilityType?: ACCESSIBILITY_TYPE[keyof ACCESSIBILITY_TYPE];
97
97
  focusLock?: boolean;
98
98
  autoFocus?: boolean;
99
- returnFocus?: boolean;
99
+ focusOptions?: FocusOptions;
100
+ returnFocus?: boolean | FocusOptions | ((returnTo: Element) => (boolean | FocusOptions));
100
101
  'data-baseweb'?: string;
101
102
  id?: string;
102
103
  ignoreBoundary?: boolean;
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
 
10
- var _reactFocusLock = _interopRequireDefault(require("react-focus-lock"));
10
+ var _reactFocusLock = _interopRequireWildcard(require("react-focus-lock"));
11
11
 
12
12
  var _overrides = require("../helpers/overrides.js");
13
13
 
@@ -213,7 +213,7 @@ var PopoverInner = /*#__PURE__*/function (_React$Component) {
213
213
  value: function componentDidUpdate(prevProps, prevState) {
214
214
  this.init(prevProps, prevState);
215
215
 
216
- if (this.props.autoFocus && this.props.focusLock && !this.state.autoFocusAfterPositioning && this.popperRef.current !== null && this.popperRef.current.getBoundingClientRect().top > 0) {
216
+ if (this.props.autoFocus && !this.state.autoFocusAfterPositioning && this.popperRef.current !== null && this.popperRef.current.getBoundingClientRect().top > 0) {
217
217
  this.setState({
218
218
  autoFocusAfterPositioning: true
219
219
  });
@@ -529,9 +529,10 @@ var PopoverInner = /*#__PURE__*/function (_React$Component) {
529
529
  disabled: !this.props.focusLock,
530
530
  noFocusGuards: false // see popover-focus-loop.scenario.js for why hover cannot return focus
531
531
  ,
532
- returnFocus: this.props.returnFocus && !this.isHoverTrigger(),
533
- autoFocus: this.state.autoFocusAfterPositioning
534
- }, this.renderPopover(renderedContent)))));
532
+ returnFocus: !this.isHoverTrigger() && this.props.returnFocus,
533
+ autoFocus: this.state.autoFocusAfterPositioning,
534
+ focusOptions: this.props.focusOptions
535
+ }, !this.props.focusLock && this.state.autoFocusAfterPositioning ? /*#__PURE__*/React.createElement(_reactFocusLock.MoveFocusInside, null, this.renderPopover(renderedContent)) : this.renderPopover(renderedContent)))));
535
536
  } else {
536
537
  rendered.push( /*#__PURE__*/React.createElement(_styledComponents.Hidden, {
537
538
  key: "hidden-layer"
@@ -8,7 +8,7 @@ LICENSE file in the root directory of this source tree.
8
8
  /* eslint-disable react/no-find-dom-node */
9
9
  /* eslint-disable cup/no-undef */
10
10
  import * as React from 'react';
11
- import FocusLock from 'react-focus-lock';
11
+ import FocusLock, {MoveFocusInside} from 'react-focus-lock';
12
12
 
13
13
  import {getOverride, getOverrideProps} from '../helpers/overrides.js';
14
14
  import {
@@ -73,7 +73,6 @@ class PopoverInner extends React.Component<
73
73
  this.init(prevProps, prevState);
74
74
  if (
75
75
  this.props.autoFocus &&
76
- this.props.focusLock &&
77
76
  !this.state.autoFocusAfterPositioning &&
78
77
  this.popperRef.current !== null &&
79
78
  this.popperRef.current.getBoundingClientRect().top > 0
@@ -475,10 +474,18 @@ class PopoverInner extends React.Component<
475
474
  disabled={!this.props.focusLock}
476
475
  noFocusGuards={false}
477
476
  // see popover-focus-loop.scenario.js for why hover cannot return focus
478
- returnFocus={this.props.returnFocus && !this.isHoverTrigger()}
477
+ returnFocus={!this.isHoverTrigger() && this.props.returnFocus}
479
478
  autoFocus={this.state.autoFocusAfterPositioning}
479
+ focusOptions={this.props.focusOptions}
480
480
  >
481
- {this.renderPopover(renderedContent)}
481
+ {!this.props.focusLock &&
482
+ this.state.autoFocusAfterPositioning ? (
483
+ <MoveFocusInside>
484
+ {this.renderPopover(renderedContent)}
485
+ </MoveFocusInside>
486
+ ) : (
487
+ this.renderPopover(renderedContent)
488
+ )}
482
489
  </FocusLock>
483
490
  </TetherBehavior>
484
491
  </Layer>,
@@ -70,6 +70,10 @@ var StatefulContainer = /*#__PURE__*/function (_React$Component) {
70
70
  _this.props.onBlur(e);
71
71
  }
72
72
 
73
+ if (_this.props.focusLock || _this.props.autoFocus) {
74
+ return;
75
+ }
76
+
73
77
  _this.close();
74
78
  });
75
79
 
@@ -208,7 +212,8 @@ var StatefulContainer = /*#__PURE__*/function (_React$Component) {
208
212
  returnFocus = _this$props.returnFocus,
209
213
  showArrow = _this$props.showArrow,
210
214
  triggerType = _this$props.triggerType,
211
- popoverMargin = _this$props.popoverMargin;
215
+ popoverMargin = _this$props.popoverMargin,
216
+ focusOptions = _this$props.focusOptions;
212
217
  var popoverProps = {
213
218
  accessibilityType: accessibilityType,
214
219
  autoFocus: autoFocus,
@@ -231,7 +236,8 @@ var StatefulContainer = /*#__PURE__*/function (_React$Component) {
231
236
  returnFocus: returnFocus,
232
237
  showArrow: showArrow,
233
238
  triggerType: triggerType,
234
- popoverMargin: popoverMargin
239
+ popoverMargin: popoverMargin,
240
+ focusOptions: focusOptions
235
241
  };
236
242
 
237
243
  if (dismissOnClickOutside) {
@@ -52,6 +52,9 @@ class StatefulContainer extends React.Component<
52
52
  if (this.props.onBlur) {
53
53
  this.props.onBlur(e);
54
54
  }
55
+ if (this.props.focusLock || this.props.autoFocus) {
56
+ return;
57
+ }
55
58
  this.close();
56
59
  };
57
60
 
@@ -168,6 +171,7 @@ class StatefulContainer extends React.Component<
168
171
  showArrow,
169
172
  triggerType,
170
173
  popoverMargin,
174
+ focusOptions,
171
175
  } = this.props;
172
176
 
173
177
  const popoverProps: PopoverPropsWithoutChildrenT = {
@@ -193,6 +197,7 @@ class StatefulContainer extends React.Component<
193
197
  showArrow,
194
198
  triggerType,
195
199
  popoverMargin,
200
+ focusOptions,
196
201
  };
197
202
 
198
203
  if (dismissOnClickOutside) {
@@ -83,6 +83,8 @@ export type BasePopoverPropsT = {
83
83
  onClick?: (e: Event) => mixed,
84
84
  /** Handler for 'Esc' keypress events */
85
85
  onFocus?: (e: Event) => mixed,
86
+ /** Pass FocusOptions for focusing (used as `HtmlElement.focus(focusOptions)`) */
87
+ focusOptions?: FocusOptions,
86
88
  /** Handler for mouseenter events on trigger element. */
87
89
  onMouseEnter?: (e: Event) => mixed,
88
90
  /** Number of milliseconds to wait before showing the popover after mouse enters the trigger element (for triggerType `hover`). */
@@ -104,7 +106,10 @@ export type BasePopoverPropsT = {
104
106
  /** If true, focus will shift back to the original element that triggered the popover
105
107
  * Be careful with elements that open the popover on focus (e.g. input) this will cause the popover to reopen on close!
106
108
  */
107
- returnFocus?: boolean,
109
+ returnFocus?:
110
+ | boolean
111
+ | FocusOptions
112
+ | ((returnTo: Element) => boolean | FocusOptions),
108
113
  /** Whether or not to show the arrow pointing from the popover to the trigger. */
109
114
  showArrow?: boolean,
110
115
  /** Whether to toggle the popover when trigger is clicked or hovered. */
@@ -222,8 +222,8 @@ var EmoticonRating = /*#__PURE__*/function (_React$Component) {
222
222
  return /*#__PURE__*/React.createElement(Root, _extends({
223
223
  "data-baseweb": "emoticon-rating",
224
224
  role: "radiogroup",
225
- onBlur: function onBlur() {
226
- return _this2.updatePreview(undefined);
225
+ onBlur: function onBlur(e) {
226
+ if (!e.currentTarget.contains(e.relatedTarget)) _this2.updatePreview(undefined);
227
227
  },
228
228
  onMouseLeave: function onMouseLeave() {
229
229
  return _this2.updatePreview(undefined);
@@ -135,7 +135,10 @@ class EmoticonRating extends React.Component<
135
135
  <Root
136
136
  data-baseweb="emoticon-rating"
137
137
  role="radiogroup"
138
- onBlur={() => this.updatePreview(undefined)}
138
+ onBlur={e => {
139
+ if (!e.currentTarget.contains(e.relatedTarget))
140
+ this.updatePreview(undefined);
141
+ }}
139
142
  onMouseLeave={() => this.updatePreview(undefined)}
140
143
  {...rootProps}
141
144
  >
@@ -225,8 +225,8 @@ var StarRating = /*#__PURE__*/function (_React$Component) {
225
225
  return /*#__PURE__*/React.createElement(Root, _extends({
226
226
  "data-baseweb": "star-rating",
227
227
  role: "radiogroup",
228
- onBlur: function onBlur() {
229
- return _this2.updatePreview(undefined);
228
+ onBlur: function onBlur(e) {
229
+ if (!e.currentTarget.contains(e.relatedTarget)) _this2.updatePreview(undefined);
230
230
  },
231
231
  onMouseLeave: function onMouseLeave() {
232
232
  return _this2.updatePreview(undefined);
@@ -133,7 +133,10 @@ class StarRating extends React.Component<StarRatingPropsT, RatingStateT> {
133
133
  <Root
134
134
  data-baseweb="star-rating"
135
135
  role="radiogroup"
136
- onBlur={() => this.updatePreview(undefined)}
136
+ onBlur={e => {
137
+ if (!e.currentTarget.contains(e.relatedTarget))
138
+ this.updatePreview(undefined);
139
+ }}
137
140
  onMouseLeave={() => this.updatePreview(undefined)}
138
141
  {...rootProps}
139
142
  >
@@ -180,7 +180,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
180
180
  isPseudoFocused: false
181
181
  });
182
182
 
183
- _defineProperty(_assertThisInitialized(_this), "isMounted", false);
183
+ _defineProperty(_assertThisInitialized(_this), "isItMounted", false);
184
184
 
185
185
  _defineProperty(_assertThisInitialized(_this), "handleTouchOutside", function (event) {
186
186
  if (containsNode(_this.dropdown.current, event.target)) return;
@@ -328,7 +328,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
328
328
  _this.props.onBlur(event);
329
329
  }
330
330
 
331
- if (_this.isMounted) {
331
+ if (_this.isItMounted) {
332
332
  _this.setState({
333
333
  isFocused: false,
334
334
  isOpen: false,
@@ -682,7 +682,14 @@ var Select = /*#__PURE__*/function (_React$Component) {
682
682
  this.focus();
683
683
  }
684
684
 
685
- this.isMounted = true;
685
+ this.isItMounted = true;
686
+
687
+ if (this.props.methodsRef) {
688
+ var methodsRef = this.props.methodsRef;
689
+ methodsRef.current = {
690
+ setDropdownOpen: this.handleDropdownOpen.bind(this)
691
+ };
692
+ }
686
693
  }
687
694
  }, {
688
695
  key: "componentDidUpdate",
@@ -711,13 +718,20 @@ var Select = /*#__PURE__*/function (_React$Component) {
711
718
  document.removeEventListener('click', this.handleClickOutside);
712
719
  }
713
720
 
714
- this.isMounted = false;
721
+ this.isItMounted = false;
715
722
  }
716
723
  }, {
717
724
  key: "focus",
718
725
  value: function focus() {
719
726
  if (!this.input) return;
720
727
  this.input.focus();
728
+ }
729
+ }, {
730
+ key: "handleDropdownOpen",
731
+ value: function handleDropdownOpen(nextOpenState) {
732
+ this.setState({
733
+ isOpen: nextOpenState
734
+ });
721
735
  } // Handle touch outside on mobile to dismiss menu, ensures that the
722
736
  // touch target is not within the anchor DOM node.
723
737
 
@@ -933,7 +947,6 @@ var Select = /*#__PURE__*/function (_React$Component) {
933
947
 
934
948
  var ariaLabel = this.props.multi ? 'Clear all' : 'Clear value';
935
949
  return /*#__PURE__*/React.createElement(ClearIcon, _extends({
936
- size: 16,
937
950
  title: ariaLabel,
938
951
  "aria-label": ariaLabel,
939
952
  onClick: this.clearValue,
@@ -1155,6 +1168,7 @@ var Select = /*#__PURE__*/function (_React$Component) {
1155
1168
  if (!ref) return;
1156
1169
  _this6.anchor = ref.anchorRef;
1157
1170
  },
1171
+ autoFocus: false,
1158
1172
  focusLock: false,
1159
1173
  mountNode: _this6.props.mountNode,
1160
1174
  onEsc: function onEsc() {
@@ -117,13 +117,21 @@ class Select extends React.Component<PropsT, SelectStateT> {
117
117
  isPseudoFocused: false,
118
118
  };
119
119
 
120
- isMounted: boolean = false;
120
+ isItMounted: boolean = false;
121
121
 
122
122
  componentDidMount() {
123
123
  if (this.props.autoFocus) {
124
124
  this.focus();
125
125
  }
126
- this.isMounted = true;
126
+ this.isItMounted = true;
127
+
128
+ if (this.props.methodsRef) {
129
+ const {methodsRef} = this.props;
130
+
131
+ methodsRef.current = {
132
+ setDropdownOpen: this.handleDropdownOpen.bind(this),
133
+ };
134
+ }
127
135
  }
128
136
 
129
137
  componentDidUpdate(prevProps: PropsT, prevState: SelectStateT) {
@@ -149,7 +157,7 @@ class Select extends React.Component<PropsT, SelectStateT> {
149
157
  document.removeEventListener('touchstart', this.handleTouchOutside);
150
158
  document.removeEventListener('click', this.handleClickOutside);
151
159
  }
152
- this.isMounted = false;
160
+ this.isItMounted = false;
153
161
  }
154
162
 
155
163
  focus() {
@@ -157,6 +165,12 @@ class Select extends React.Component<PropsT, SelectStateT> {
157
165
  this.input.focus();
158
166
  }
159
167
 
168
+ handleDropdownOpen(nextOpenState: boolean) {
169
+ this.setState({
170
+ isOpen: nextOpenState,
171
+ });
172
+ }
173
+
160
174
  // Handle touch outside on mobile to dismiss menu, ensures that the
161
175
  // touch target is not within the anchor DOM node.
162
176
  handleTouchOutside = (event: TouchEvent) => {
@@ -305,7 +319,7 @@ class Select extends React.Component<PropsT, SelectStateT> {
305
319
  this.props.onBlur(event);
306
320
  }
307
321
 
308
- if (this.isMounted) {
322
+ if (this.isItMounted) {
309
323
  this.setState({
310
324
  isFocused: false,
311
325
  isOpen: false,
@@ -779,7 +793,6 @@ class Select extends React.Component<PropsT, SelectStateT> {
779
793
 
780
794
  return (
781
795
  <ClearIcon
782
- size={16}
783
796
  title={ariaLabel}
784
797
  aria-label={ariaLabel}
785
798
  onClick={this.clearValue}
@@ -1012,6 +1025,7 @@ class Select extends React.Component<PropsT, SelectStateT> {
1012
1025
  if (!ref) return;
1013
1026
  this.anchor = ref.anchorRef;
1014
1027
  }}
1028
+ autoFocus={false}
1015
1029
  focusLock={false}
1016
1030
  mountNode={this.props.mountNode}
1017
1031
  onEsc={() => this.closeMenu()}
@@ -342,26 +342,50 @@ function getSvgStyles(_ref4) {
342
342
  }
343
343
 
344
344
  var StyledSelectArrow = (0, _index.styled)('svg', function (props) {
345
+ var _sizes;
346
+
345
347
  var $theme = props.$theme,
346
- $disabled = props.$disabled;
348
+ $disabled = props.$disabled,
349
+ $size = props.$size;
347
350
  var colors = $theme.colors;
351
+ var sizes = (_sizes = {}, _defineProperty(_sizes, _constants.SIZE.mini, 16), _defineProperty(_sizes, _constants.SIZE.compact, 16), _defineProperty(_sizes, _constants.SIZE.default, 20), _defineProperty(_sizes, _constants.SIZE.large, 24), _sizes);
352
+ var size = sizes[_constants.SIZE.default];
353
+
354
+ if ($size) {
355
+ size = sizes[$size];
356
+ }
357
+
348
358
  return _objectSpread(_objectSpread({}, getSvgStyles({
349
359
  $theme: $theme
350
360
  })), {}, {
351
361
  color: $disabled ? colors.inputTextDisabled : colors.contentPrimary,
352
- cursor: $disabled ? 'not-allowed' : 'pointer'
362
+ cursor: $disabled ? 'not-allowed' : 'pointer',
363
+ height: "".concat(size, "px"),
364
+ width: "".concat(size, "px")
353
365
  });
354
366
  });
355
367
  exports.StyledSelectArrow = StyledSelectArrow;
356
368
  StyledSelectArrow.displayName = "StyledSelectArrow";
357
369
  var StyledClearIcon = (0, _index.styled)('svg', function (props) {
358
- var $theme = props.$theme;
370
+ var _sizes2;
371
+
372
+ var $theme = props.$theme,
373
+ $size = props.$size;
359
374
  var colors = $theme.colors;
375
+ var sizes = (_sizes2 = {}, _defineProperty(_sizes2, _constants.SIZE.mini, 15), _defineProperty(_sizes2, _constants.SIZE.compact, 15), _defineProperty(_sizes2, _constants.SIZE.default, 18), _defineProperty(_sizes2, _constants.SIZE.large, 22), _sizes2);
376
+ var size = sizes[_constants.SIZE.default];
377
+
378
+ if ($size) {
379
+ size = sizes[$size];
380
+ }
381
+
360
382
  return _objectSpread(_objectSpread({}, getSvgStyles({
361
383
  $theme: $theme
362
384
  })), {}, {
363
385
  color: colors.contentPrimary,
364
- cursor: 'pointer'
386
+ cursor: 'pointer',
387
+ height: "".concat(size, "px"),
388
+ width: "".concat(size, "px")
365
389
  });
366
390
  });
367
391
  exports.StyledClearIcon = StyledClearIcon;