baseui 0.0.0-next-bb97580 → 0.0.0-next-73dd693

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.
@@ -306,7 +306,11 @@ function Combobox(props) {
306
306
  return /*#__PURE__*/React.createElement(Root // eslint-disable-next-line flowtype/no-weak-types
307
307
  , _extends({
308
308
  ref: rootRef
309
- }, rootProps), /*#__PURE__*/React.createElement(OverriddenPopover, _extends({
309
+ }, rootProps), /*#__PURE__*/React.createElement(OverriddenPopover // React-focus-lock used in Popover used to skip non-tabbable elements (`tabIndex=-1`) elements for focus, we had ListBox with tabIndex to disable focus on
310
+ // the ListBox, but we can just disable autoFocus (as ListBox / ListItem should not be focusable) (and input is also not autoFocused).
311
+ // Select Component does the same thing
312
+ , _extends({
313
+ autoFocus: false,
310
314
  isOpen: isOpen,
311
315
  overrides: popoverOverrides,
312
316
  placement: _index2.PLACEMENT.bottomLeft,
@@ -258,6 +258,10 @@ function Combobox<OptionT>(props: PropsT<OptionT>) {
258
258
  {...rootProps}
259
259
  >
260
260
  <OverriddenPopover
261
+ // React-focus-lock used in Popover used to skip non-tabbable elements (`tabIndex=-1`) elements for focus, we had ListBox with tabIndex to disable focus on
262
+ // the ListBox, but we can just disable autoFocus (as ListBox / ListItem should not be focusable) (and input is also not autoFocused).
263
+ // Select Component does the same thing
264
+ autoFocus={false}
261
265
  isOpen={isOpen}
262
266
  overrides={popoverOverrides}
263
267
  placement={PLACEMENT.bottomLeft}
package/dnd-list/list.js CHANGED
@@ -220,8 +220,7 @@ var StatelessList = /*#__PURE__*/function (_React$Component) {
220
220
  display: 'flex'
221
221
  })
222
222
  }), /*#__PURE__*/React.createElement(DragHandle, _extends({}, sharedProps, dragHandleProps), /*#__PURE__*/React.createElement(_grab.default, {
223
- size: 24,
224
- color: "#CCC"
223
+ size: 24
225
224
  })), /*#__PURE__*/React.createElement(Label, _extends({}, sharedProps, labelProps), value), removable && /*#__PURE__*/React.createElement(CloseHandle, _extends({}, sharedProps, {
226
225
  onClick: function onClick(evt) {
227
226
  evt.preventDefault();
@@ -136,7 +136,7 @@ class StatelessList extends React.Component<
136
136
  style={{...props.style, display: 'flex'}}
137
137
  >
138
138
  <DragHandle {...sharedProps} {...dragHandleProps}>
139
- <Grab size={24} color="#CCC" />
139
+ <Grab size={24} />
140
140
  </DragHandle>
141
141
  <Label {...sharedProps} {...labelProps}>
142
142
  {value}
@@ -94,7 +94,7 @@ var DragHandle = (0, _index.styled)('div', function (_ref4) {
94
94
 
95
95
  var $theme = _ref4.$theme;
96
96
  var marginDir = $theme.direction === 'rtl' ? 'marginLeft' : 'marginRight';
97
- return _ref5 = {}, _defineProperty(_ref5, marginDir, $theme.sizing.scale600), _defineProperty(_ref5, "width", $theme.sizing.scale800), _defineProperty(_ref5, "display", 'flex'), _defineProperty(_ref5, "alignItems", 'center'), _ref5;
97
+ return _ref5 = {}, _defineProperty(_ref5, marginDir, $theme.sizing.scale600), _defineProperty(_ref5, "width", $theme.sizing.scale800), _defineProperty(_ref5, "color", '#CCC'), _defineProperty(_ref5, "display", 'flex'), _defineProperty(_ref5, "alignItems", 'center'), _ref5;
98
98
  });
99
99
  exports.DragHandle = DragHandle;
100
100
  DragHandle.displayName = "DragHandle";
@@ -94,6 +94,7 @@ export const DragHandle = styled<SharedStylePropsArgT>('div', ({$theme}) => {
94
94
  return {
95
95
  [marginDir]: $theme.sizing.scale600,
96
96
  width: $theme.sizing.scale800,
97
+ color: '#CCC',
97
98
  display: 'flex',
98
99
  alignItems: 'center',
99
100
  };
@@ -235,7 +235,11 @@ function Combobox(props) {
235
235
  return /*#__PURE__*/React.createElement(Root // eslint-disable-next-line flowtype/no-weak-types
236
236
  , _extends({
237
237
  ref: rootRef
238
- }, rootProps), /*#__PURE__*/React.createElement(OverriddenPopover, _extends({
238
+ }, rootProps), /*#__PURE__*/React.createElement(OverriddenPopover // React-focus-lock used in Popover used to skip non-tabbable elements (`tabIndex=-1`) elements for focus, we had ListBox with tabIndex to disable focus on
239
+ // the ListBox, but we can just disable autoFocus (as ListBox / ListItem should not be focusable) (and input is also not autoFocused).
240
+ // Select Component does the same thing
241
+ , _extends({
242
+ autoFocus: false,
239
243
  isOpen: isOpen,
240
244
  overrides: popoverOverrides,
241
245
  placement: PLACEMENT.bottomLeft,
@@ -127,8 +127,7 @@ class StatelessList extends React.Component {
127
127
  display: 'flex'
128
128
  }
129
129
  }), /*#__PURE__*/React.createElement(DragHandle, _extends({}, sharedProps, dragHandleProps), /*#__PURE__*/React.createElement(Grab, {
130
- size: 24,
131
- color: "#CCC"
130
+ size: 24
132
131
  })), /*#__PURE__*/React.createElement(Label, _extends({}, sharedProps, labelProps), value), removable && /*#__PURE__*/React.createElement(CloseHandle, _extends({}, sharedProps, {
133
132
  onClick: evt => {
134
133
  evt.preventDefault();
@@ -89,6 +89,7 @@ export const DragHandle = styled('div', ({
89
89
  return {
90
90
  [marginDir]: $theme.sizing.scale600,
91
91
  width: $theme.sizing.scale800,
92
+ color: '#CCC',
92
93
  display: 'flex',
93
94
  alignItems: 'center'
94
95
  };
@@ -451,8 +451,9 @@ class PopoverInner extends React.Component {
451
451
  disabled: !this.props.focusLock,
452
452
  noFocusGuards: false // see popover-focus-loop.scenario.js for why hover cannot return focus
453
453
  ,
454
- returnFocus: this.props.returnFocus && !this.isHoverTrigger(),
455
- autoFocus: this.state.autoFocusAfterPositioning
454
+ returnFocus: !this.isHoverTrigger() && this.props.returnFocus,
455
+ autoFocus: this.state.autoFocusAfterPositioning,
456
+ focusOptions: this.props.focusOptions
456
457
  }, !this.props.focusLock && this.state.autoFocusAfterPositioning ? /*#__PURE__*/React.createElement(MoveFocusInside, null, this.renderPopover(renderedContent)) : this.renderPopover(renderedContent)))));
457
458
  } else {
458
459
  rendered.push( /*#__PURE__*/React.createElement(Hidden, {
@@ -162,7 +162,8 @@ class StatefulContainer extends React.Component {
162
162
  returnFocus,
163
163
  showArrow,
164
164
  triggerType,
165
- popoverMargin
165
+ popoverMargin,
166
+ focusOptions
166
167
  } = this.props;
167
168
  const popoverProps = {
168
169
  accessibilityType,
@@ -186,7 +187,8 @@ class StatefulContainer extends React.Component {
186
187
  returnFocus,
187
188
  showArrow,
188
189
  triggerType,
189
- popoverMargin
190
+ popoverMargin,
191
+ focusOptions
190
192
  };
191
193
 
192
194
  if (dismissOnClickOutside) {
@@ -292,7 +292,11 @@ function Combobox(props) {
292
292
  return /*#__PURE__*/React.createElement(Root // eslint-disable-next-line flowtype/no-weak-types
293
293
  , _extends({
294
294
  ref: rootRef
295
- }, rootProps), /*#__PURE__*/React.createElement(OverriddenPopover, _extends({
295
+ }, rootProps), /*#__PURE__*/React.createElement(OverriddenPopover // React-focus-lock used in Popover used to skip non-tabbable elements (`tabIndex=-1`) elements for focus, we had ListBox with tabIndex to disable focus on
296
+ // the ListBox, but we can just disable autoFocus (as ListBox / ListItem should not be focusable) (and input is also not autoFocused).
297
+ // Select Component does the same thing
298
+ , _extends({
299
+ autoFocus: false,
296
300
  isOpen: isOpen,
297
301
  overrides: popoverOverrides,
298
302
  placement: PLACEMENT.bottomLeft,
@@ -206,8 +206,7 @@ var StatelessList = /*#__PURE__*/function (_React$Component) {
206
206
  display: 'flex'
207
207
  })
208
208
  }), /*#__PURE__*/React.createElement(DragHandle, _extends({}, sharedProps, dragHandleProps), /*#__PURE__*/React.createElement(Grab, {
209
- size: 24,
210
- color: "#CCC"
209
+ size: 24
211
210
  })), /*#__PURE__*/React.createElement(Label, _extends({}, sharedProps, labelProps), value), removable && /*#__PURE__*/React.createElement(CloseHandle, _extends({}, sharedProps, {
212
211
  onClick: function onClick(evt) {
213
212
  evt.preventDefault();
@@ -90,7 +90,7 @@ export var DragHandle = styled('div', function (_ref4) {
90
90
 
91
91
  var $theme = _ref4.$theme;
92
92
  var marginDir = $theme.direction === 'rtl' ? 'marginLeft' : 'marginRight';
93
- return _ref5 = {}, _defineProperty(_ref5, marginDir, $theme.sizing.scale600), _defineProperty(_ref5, "width", $theme.sizing.scale800), _defineProperty(_ref5, "display", 'flex'), _defineProperty(_ref5, "alignItems", 'center'), _ref5;
93
+ return _ref5 = {}, _defineProperty(_ref5, marginDir, $theme.sizing.scale600), _defineProperty(_ref5, "width", $theme.sizing.scale800), _defineProperty(_ref5, "color", '#CCC'), _defineProperty(_ref5, "display", 'flex'), _defineProperty(_ref5, "alignItems", 'center'), _ref5;
94
94
  });
95
95
  DragHandle.displayName = "DragHandle";
96
96
  DragHandle.displayName = 'StyledDragHandle';
@@ -514,8 +514,9 @@ var PopoverInner = /*#__PURE__*/function (_React$Component) {
514
514
  disabled: !this.props.focusLock,
515
515
  noFocusGuards: false // see popover-focus-loop.scenario.js for why hover cannot return focus
516
516
  ,
517
- returnFocus: this.props.returnFocus && !this.isHoverTrigger(),
518
- autoFocus: this.state.autoFocusAfterPositioning
517
+ returnFocus: !this.isHoverTrigger() && this.props.returnFocus,
518
+ autoFocus: this.state.autoFocusAfterPositioning,
519
+ focusOptions: this.props.focusOptions
519
520
  }, !this.props.focusLock && this.state.autoFocusAfterPositioning ? /*#__PURE__*/React.createElement(MoveFocusInside, null, this.renderPopover(renderedContent)) : this.renderPopover(renderedContent)))));
520
521
  } else {
521
522
  rendered.push( /*#__PURE__*/React.createElement(Hidden, {
@@ -206,7 +206,8 @@ var StatefulContainer = /*#__PURE__*/function (_React$Component) {
206
206
  returnFocus = _this$props.returnFocus,
207
207
  showArrow = _this$props.showArrow,
208
208
  triggerType = _this$props.triggerType,
209
- popoverMargin = _this$props.popoverMargin;
209
+ popoverMargin = _this$props.popoverMargin,
210
+ focusOptions = _this$props.focusOptions;
210
211
  var popoverProps = {
211
212
  accessibilityType: accessibilityType,
212
213
  autoFocus: autoFocus,
@@ -229,7 +230,8 @@ var StatefulContainer = /*#__PURE__*/function (_React$Component) {
229
230
  returnFocus: returnFocus,
230
231
  showArrow: showArrow,
231
232
  triggerType: triggerType,
232
- popoverMargin: popoverMargin
233
+ popoverMargin: popoverMargin,
234
+ focusOptions: focusOptions
233
235
  };
234
236
 
235
237
  if (dismissOnClickOutside) {
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": "0.0.0-next-bb97580",
3
+ "version": "0.0.0-next-73dd693",
4
4
  "description": "A React Component library implementing the Base design language",
5
5
  "keywords": [
6
6
  "react",
@@ -201,7 +201,7 @@
201
201
  "polished": "^3.2.0",
202
202
  "popper.js": "^1.16.0",
203
203
  "react-dropzone": "^9.0.0",
204
- "react-focus-lock": "^2.2.1",
204
+ "react-focus-lock": "^2.7.1",
205
205
  "react-input-mask": "^2.0.4",
206
206
  "react-is": "^16.8.6",
207
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;
@@ -529,8 +529,9 @@ 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
532
+ returnFocus: !this.isHoverTrigger() && this.props.returnFocus,
533
+ autoFocus: this.state.autoFocusAfterPositioning,
534
+ focusOptions: this.props.focusOptions
534
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, {
@@ -474,8 +474,9 @@ class PopoverInner extends React.Component<
474
474
  disabled={!this.props.focusLock}
475
475
  noFocusGuards={false}
476
476
  // see popover-focus-loop.scenario.js for why hover cannot return focus
477
- returnFocus={this.props.returnFocus && !this.isHoverTrigger()}
477
+ returnFocus={!this.isHoverTrigger() && this.props.returnFocus}
478
478
  autoFocus={this.state.autoFocusAfterPositioning}
479
+ focusOptions={this.props.focusOptions}
479
480
  >
480
481
  {!this.props.focusLock &&
481
482
  this.state.autoFocusAfterPositioning ? (
@@ -212,7 +212,8 @@ var StatefulContainer = /*#__PURE__*/function (_React$Component) {
212
212
  returnFocus = _this$props.returnFocus,
213
213
  showArrow = _this$props.showArrow,
214
214
  triggerType = _this$props.triggerType,
215
- popoverMargin = _this$props.popoverMargin;
215
+ popoverMargin = _this$props.popoverMargin,
216
+ focusOptions = _this$props.focusOptions;
216
217
  var popoverProps = {
217
218
  accessibilityType: accessibilityType,
218
219
  autoFocus: autoFocus,
@@ -235,7 +236,8 @@ var StatefulContainer = /*#__PURE__*/function (_React$Component) {
235
236
  returnFocus: returnFocus,
236
237
  showArrow: showArrow,
237
238
  triggerType: triggerType,
238
- popoverMargin: popoverMargin
239
+ popoverMargin: popoverMargin,
240
+ focusOptions: focusOptions
239
241
  };
240
242
 
241
243
  if (dismissOnClickOutside) {
@@ -171,6 +171,7 @@ class StatefulContainer extends React.Component<
171
171
  showArrow,
172
172
  triggerType,
173
173
  popoverMargin,
174
+ focusOptions,
174
175
  } = this.props;
175
176
 
176
177
  const popoverProps: PopoverPropsWithoutChildrenT = {
@@ -196,6 +197,7 @@ class StatefulContainer extends React.Component<
196
197
  showArrow,
197
198
  triggerType,
198
199
  popoverMargin,
200
+ focusOptions,
199
201
  };
200
202
 
201
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. */