@itwin/itwinui-react 3.0.0-dev.8 → 3.0.0-dev.9

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 (61) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/cjs/core/Buttons/DropdownButton/DropdownButton.js +7 -19
  3. package/cjs/core/Buttons/SplitButton/SplitButton.d.ts +4 -4
  4. package/cjs/core/Buttons/SplitButton/SplitButton.js +53 -31
  5. package/cjs/core/ComboBox/ComboBox.d.ts +2 -2
  6. package/cjs/core/ComboBox/ComboBox.js +32 -24
  7. package/cjs/core/ComboBox/ComboBoxInput.js +29 -21
  8. package/cjs/core/ComboBox/ComboBoxMenu.js +73 -93
  9. package/cjs/core/ComboBox/helpers.d.ts +4 -1
  10. package/cjs/core/DropdownMenu/DropdownMenu.d.ts +6 -5
  11. package/cjs/core/DropdownMenu/DropdownMenu.js +59 -55
  12. package/cjs/core/Header/HeaderDropdownButton.js +1 -2
  13. package/cjs/core/Header/HeaderSplitButton.js +1 -2
  14. package/cjs/core/Menu/Menu.js +1 -1
  15. package/cjs/core/Menu/MenuItem.js +77 -55
  16. package/cjs/core/Select/Select.d.ts +5 -5
  17. package/cjs/core/Select/Select.js +74 -93
  18. package/cjs/core/Table/columns/actionColumn.js +3 -7
  19. package/cjs/core/Table/filters/DateRangeFilter/DatePickerInput.js +36 -41
  20. package/cjs/core/Table/filters/FilterToggle.js +3 -2
  21. package/cjs/core/Tile/Tile.js +21 -22
  22. package/cjs/core/index.d.ts +1 -1
  23. package/cjs/core/index.js +8 -1
  24. package/cjs/core/utils/components/InputContainer.d.ts +4 -4
  25. package/cjs/core/utils/components/InputContainer.js +7 -3
  26. package/cjs/core/utils/components/Popover.d.ts +113 -27
  27. package/cjs/core/utils/components/Popover.js +156 -118
  28. package/cjs/styles.js +2 -5
  29. package/esm/core/Buttons/DropdownButton/DropdownButton.js +8 -24
  30. package/esm/core/Buttons/SplitButton/SplitButton.d.ts +4 -4
  31. package/esm/core/Buttons/SplitButton/SplitButton.js +53 -28
  32. package/esm/core/ComboBox/ComboBox.d.ts +2 -2
  33. package/esm/core/ComboBox/ComboBox.js +33 -24
  34. package/esm/core/ComboBox/ComboBoxInput.js +22 -21
  35. package/esm/core/ComboBox/ComboBoxMenu.js +67 -87
  36. package/esm/core/ComboBox/helpers.d.ts +4 -1
  37. package/esm/core/DropdownMenu/DropdownMenu.d.ts +6 -5
  38. package/esm/core/DropdownMenu/DropdownMenu.js +64 -56
  39. package/esm/core/Header/HeaderDropdownButton.js +1 -2
  40. package/esm/core/Header/HeaderSplitButton.js +1 -2
  41. package/esm/core/Menu/Menu.js +7 -2
  42. package/esm/core/Menu/MenuItem.js +84 -52
  43. package/esm/core/Select/Select.d.ts +5 -5
  44. package/esm/core/Select/Select.js +74 -90
  45. package/esm/core/Table/columns/actionColumn.js +3 -7
  46. package/esm/core/Table/filters/DateRangeFilter/DatePickerInput.js +36 -41
  47. package/esm/core/Table/filters/FilterToggle.js +3 -2
  48. package/esm/core/Tile/Tile.js +21 -22
  49. package/esm/core/index.d.ts +1 -1
  50. package/esm/core/index.js +1 -0
  51. package/esm/core/utils/components/InputContainer.d.ts +4 -4
  52. package/esm/core/utils/components/InputContainer.js +7 -2
  53. package/esm/core/utils/components/Popover.d.ts +113 -27
  54. package/esm/core/utils/components/Popover.js +175 -118
  55. package/esm/styles.js +2 -5
  56. package/package.json +2 -4
  57. package/styles.css +3 -3
  58. package/cjs/core/ComboBox/ComboBoxDropdown.d.ts +0 -7
  59. package/cjs/core/ComboBox/ComboBoxDropdown.js +0 -43
  60. package/esm/core/ComboBox/ComboBoxDropdown.d.ts +0 -7
  61. package/esm/core/ComboBox/ComboBoxDropdown.js +0 -37
@@ -85,55 +85,27 @@ const Select = (props) => {
85
85
  style,
86
86
  menuClassName,
87
87
  menuStyle,
88
- onShow,
89
- onHide,
90
- popoverProps,
91
88
  multiple = false,
92
89
  triggerProps,
93
90
  status,
91
+ popoverProps,
94
92
  ...rest
95
93
  } = props;
96
- const [isOpenState, setIsOpen] = React.useState(false);
97
- const isOpen = popoverProps?.visible ?? isOpenState;
98
- const [minWidth, setMinWidth] = React.useState(0);
94
+ const [isOpen, setIsOpen] = React.useState(false);
99
95
  const [liveRegionSelection, setLiveRegionSelection] = React.useState('');
100
96
  const selectRef = React.useRef(null);
101
- const onShowHandler = React.useCallback(
102
- (instance) => {
103
- setIsOpen(true);
104
- onShow?.(instance);
105
- },
106
- [onShow],
107
- );
108
- const onHideHandler = React.useCallback(
109
- (instance) => {
110
- setIsOpen(false);
111
- selectRef.current?.focus({ preventScroll: true }); // move focus back to select button
112
- onHide?.(instance);
113
- },
114
- [onHide],
115
- );
116
- React.useEffect(() => {
117
- if (selectRef.current) {
118
- setMinWidth(selectRef.current.offsetWidth);
119
- }
120
- }, [isOpen]);
121
- const onKeyDown = (event) => {
122
- if (event.altKey) {
97
+ const show = React.useCallback(() => {
98
+ if (disabled) {
123
99
  return;
124
100
  }
125
- switch (event.key) {
126
- case 'Enter':
127
- case ' ':
128
- case 'Spacebar': {
129
- setIsOpen((o) => !o);
130
- event.preventDefault();
131
- break;
132
- }
133
- default:
134
- break;
135
- }
136
- };
101
+ setIsOpen(true);
102
+ popoverProps?.onVisibleChange?.(true);
103
+ }, [disabled, popoverProps]);
104
+ const hide = React.useCallback(() => {
105
+ setIsOpen(false);
106
+ selectRef.current?.focus({ preventScroll: true }); // move focus back to select button
107
+ popoverProps?.onVisibleChange?.(false);
108
+ }, [popoverProps]);
137
109
  const menuItems = React.useMemo(() => {
138
110
  return options.map((option, index) => {
139
111
  const isSelected = isMultipleEnabled(value, multiple)
@@ -159,7 +131,7 @@ const Select = (props) => {
159
131
  }
160
132
  if (isSingleOnChange(onChange, multiple)) {
161
133
  onChange?.(option.value);
162
- setIsOpen(false);
134
+ hide();
163
135
  } else {
164
136
  onChange?.(option.value, isSelected ? 'removed' : 'added');
165
137
  }
@@ -188,7 +160,7 @@ const Select = (props) => {
188
160
  ...menuItem.props,
189
161
  });
190
162
  });
191
- }, [itemRenderer, multiple, onChange, options, value]);
163
+ }, [hide, itemRenderer, multiple, onChange, options, value]);
192
164
  const selectedItems = React.useMemo(() => {
193
165
  if (value == null) {
194
166
  return undefined;
@@ -203,57 +175,42 @@ const Select = (props) => {
203
175
  label: item.label,
204
176
  });
205
177
  }, []);
178
+ const popover = (0, index_js_2.usePopover)({
179
+ visible: isOpen,
180
+ matchWidth: true,
181
+ closeOnOutsideClick: true,
182
+ ...popoverProps,
183
+ onVisibleChange: (open) => (open ? show() : hide()),
184
+ });
206
185
  return React.createElement(
207
- index_js_2.Box,
208
- {
209
- className: (0, classnames_1.default)('iui-input-with-icon', className),
210
- style: style,
211
- ...rest,
212
- },
186
+ React.Fragment,
187
+ null,
213
188
  React.createElement(
214
- index_js_2.Popover,
189
+ index_js_2.Box,
215
190
  {
216
- content: React.createElement(
217
- index_js_1.Menu,
218
- {
219
- role: 'listbox',
220
- className: (0, classnames_1.default)('iui-scroll', menuClassName),
221
- style: {
222
- minInlineSize: minWidth,
223
- maxInlineSize: `min(${minWidth * 2}px, 90vw)`,
224
- ...menuStyle,
225
- },
226
- id: `${uid}-menu`,
227
- key: `${uid}-menu`,
228
- },
229
- menuItems,
230
- ),
231
- placement: 'bottom-start',
232
- aria: { content: null },
233
- onShow: onShowHandler,
234
- onHide: onHideHandler,
235
- ...popoverProps,
236
- visible: isOpen,
237
- onClickOutside: () => {
238
- setIsOpen(false);
239
- },
191
+ className: (0, classnames_1.default)('iui-input-with-icon', className),
192
+ style: style,
193
+ ...rest,
194
+ ref: popover.refs.setPositionReference,
240
195
  },
241
196
  React.createElement(
242
197
  index_js_2.Box,
243
198
  {
199
+ ...popover.getReferenceProps(),
244
200
  tabIndex: 0,
245
201
  role: 'combobox',
246
- ref: selectRef,
247
202
  'data-iui-size': size,
248
203
  'data-iui-status': status,
249
- onClick: () => !disabled && setIsOpen((o) => !o),
250
- onKeyDown: (e) => !disabled && onKeyDown(e),
251
204
  'aria-disabled': disabled,
252
205
  'aria-autocomplete': 'none',
253
206
  'aria-expanded': isOpen,
254
207
  'aria-haspopup': 'listbox',
255
208
  'aria-controls': `${uid}-menu`,
256
209
  ...triggerProps,
210
+ ref: (0, index_js_2.useMergedRefs)(
211
+ selectRef,
212
+ popover.refs.setReference,
213
+ ),
257
214
  className: (0, classnames_1.default)(
258
215
  'iui-select-button',
259
216
  {
@@ -281,24 +238,48 @@ const Select = (props) => {
281
238
  selectedItemRenderer: selectedItemRenderer,
282
239
  }),
283
240
  ),
241
+ React.createElement(
242
+ index_js_2.Icon,
243
+ {
244
+ as: 'span',
245
+ 'aria-hidden': true,
246
+ className: (0, classnames_1.default)('iui-end-icon', {
247
+ 'iui-disabled': disabled,
248
+ 'iui-open': isOpen,
249
+ }),
250
+ },
251
+ React.createElement(index_js_2.SvgCaretDownSmall, null),
252
+ ),
253
+ multiple
254
+ ? React.createElement(index_js_2.AutoclearingHiddenLiveRegion, {
255
+ text: liveRegionSelection,
256
+ })
257
+ : null,
284
258
  ),
285
- React.createElement(
286
- index_js_2.Icon,
287
- {
288
- as: 'span',
289
- 'aria-hidden': true,
290
- className: (0, classnames_1.default)('iui-end-icon', {
291
- 'iui-disabled': disabled,
292
- 'iui-open': isOpen,
293
- }),
294
- },
295
- React.createElement(index_js_2.SvgCaretDownSmall, null),
296
- ),
297
- multiple
298
- ? React.createElement(index_js_2.AutoclearingHiddenLiveRegion, {
299
- text: liveRegionSelection,
300
- })
301
- : null,
259
+ popover.open &&
260
+ React.createElement(
261
+ index_js_2.Portal,
262
+ null,
263
+ React.createElement(
264
+ index_js_1.Menu,
265
+ {
266
+ role: 'listbox',
267
+ className: (0, classnames_1.default)('iui-scroll', menuClassName),
268
+ id: `${uid}-menu`,
269
+ key: `${uid}-menu`,
270
+ ...popover.getFloatingProps({
271
+ style: menuStyle,
272
+ onKeyDown: ({ key }) => {
273
+ if (key === 'Tab') {
274
+ hide();
275
+ }
276
+ },
277
+ }),
278
+ ref: popover.refs.setFloating,
279
+ },
280
+ menuItems,
281
+ ),
282
+ ),
302
283
  );
303
284
  };
304
285
  exports.Select = Select;
@@ -109,13 +109,9 @@ const ActionColumn = ({ columnManager = false } = {}) => {
109
109
  {
110
110
  ...dropdownMenuProps,
111
111
  menuItems: headerCheckBoxes,
112
- onHide: (i) => {
113
- setIsOpen(false);
114
- dropdownMenuProps.onHide?.(i);
115
- },
116
- onShow: (i) => {
117
- setIsOpen(true);
118
- dropdownMenuProps.onShow?.(i);
112
+ onVisibleChange: (open) => {
113
+ setIsOpen(open);
114
+ dropdownMenuProps?.onVisibleChange?.(open);
119
115
  },
120
116
  className: (0, classnames_1.default)(
121
117
  'iui-scroll',
@@ -69,54 +69,49 @@ const DatePickerInput = React.forwardRef((props, forwardedRef) => {
69
69
  [onChange, parseInput],
70
70
  );
71
71
  return React.createElement(
72
- index_js_1.Popover,
73
- {
74
- content: React.createElement(index_js_2.DatePicker, {
75
- date: date,
76
- onChange: onDateSelected,
77
- setFocus: true,
78
- isDateDisabled: isDateDisabled,
79
- localizedNames: localizedNames,
80
- }),
81
- placement: 'bottom',
82
- visible: isVisible,
83
- onClickOutside: (_, e) => {
84
- if (!buttonRef.current?.contains(e.target)) {
85
- close();
86
- }
72
+ index_js_3.InputGrid,
73
+ { labelPlacement: 'inline', ...wrapperProps },
74
+ React.createElement(
75
+ index_js_4.Label,
76
+ {
77
+ as: 'label',
78
+ required: required,
79
+ disabled: disabled,
80
+ htmlFor: id,
81
+ ...labelProps,
87
82
  },
88
- appendTo: 'parent',
89
- },
83
+ label,
84
+ ),
90
85
  React.createElement(
91
- index_js_3.InputGrid,
92
- { labelPlacement: 'inline', ...wrapperProps },
86
+ index_js_5.InputWithDecorations,
87
+ { ...inputWrapperProps },
88
+ React.createElement(index_js_5.InputWithDecorations.Input, {
89
+ id: id,
90
+ value: inputValue,
91
+ onChange: onInputChange,
92
+ required: required,
93
+ disabled: disabled,
94
+ ref: forwardedRef,
95
+ ...rest,
96
+ }),
93
97
  React.createElement(
94
- index_js_4.Label,
98
+ index_js_1.Popover,
95
99
  {
96
- as: 'label',
97
- required: required,
98
- disabled: disabled,
99
- htmlFor: id,
100
- ...labelProps,
100
+ content: React.createElement(index_js_2.DatePicker, {
101
+ date: date,
102
+ onChange: onDateSelected,
103
+ setFocus: true,
104
+ isDateDisabled: isDateDisabled,
105
+ localizedNames: localizedNames,
106
+ }),
107
+ placement: 'bottom-end',
108
+ visible: isVisible,
109
+ onVisibleChange: setIsVisible,
110
+ closeOnOutsideClick: true,
101
111
  },
102
- label,
103
- ),
104
- React.createElement(
105
- index_js_5.InputWithDecorations,
106
- { ...inputWrapperProps },
107
- React.createElement(index_js_5.InputWithDecorations.Input, {
108
- id: id,
109
- value: inputValue,
110
- onChange: onInputChange,
111
- onClick: close,
112
- required: required,
113
- disabled: disabled,
114
- ref: forwardedRef,
115
- ...rest,
116
- }),
117
112
  React.createElement(
118
113
  index_js_5.InputWithDecorations.Button,
119
- { onClick: () => setIsVisible((v) => !v), ref: buttonRef },
114
+ { 'aria-label': 'Date picker', ref: buttonRef },
120
115
  React.createElement(index_js_1.SvgCalendar, null),
121
116
  ),
122
117
  ),
@@ -42,7 +42,8 @@ const FilterToggle = (props) => {
42
42
  content: column.render('Filter', { close, setFilter, clearFilter }),
43
43
  placement: 'bottom-start',
44
44
  visible: isVisible,
45
- onClickOutside: close,
45
+ onVisibleChange: setIsVisible,
46
+ closeOnOutsideClick: true,
46
47
  },
47
48
  React.createElement(
48
49
  index_js_2.IconButton,
@@ -53,8 +54,8 @@ const FilterToggle = (props) => {
53
54
  'iui-table-filter-button',
54
55
  className,
55
56
  ),
57
+ 'aria-label': 'Filter',
56
58
  onClick: (e) => {
57
- setIsVisible((v) => !v);
58
59
  // Prevents from triggering sort
59
60
  e.stopPropagation();
60
61
  },
@@ -227,32 +227,31 @@ const TileMoreOptions = React.forwardRef((props, forwardedRef) => {
227
227
  const { className, children = [], buttonProps, ...rest } = props;
228
228
  const [isMenuVisible, setIsMenuVisible] = React.useState(false);
229
229
  return React.createElement(
230
- index_js_2.DropdownMenu,
230
+ index_js_1.Box,
231
231
  {
232
- onShow: React.useCallback(() => setIsMenuVisible(true), []),
233
- onHide: React.useCallback(() => setIsMenuVisible(false), []),
234
- menuItems: (close) =>
235
- children?.map((option) =>
236
- React.cloneElement(option, {
237
- onClick: (value) => {
238
- close();
239
- option.props.onClick?.(value);
240
- },
241
- }),
242
- ),
232
+ className: (0, classnames_1.default)(
233
+ 'iui-tile-more-options',
234
+ {
235
+ 'iui-visible': isMenuVisible,
236
+ },
237
+ className,
238
+ ),
239
+ ref: forwardedRef,
240
+ ...rest,
243
241
  },
244
242
  React.createElement(
245
- index_js_1.Box,
243
+ index_js_2.DropdownMenu,
246
244
  {
247
- className: (0, classnames_1.default)(
248
- 'iui-tile-more-options',
249
- {
250
- 'iui-visible': isMenuVisible,
251
- },
252
- className,
253
- ),
254
- ref: forwardedRef,
255
- ...rest,
245
+ onVisibleChange: setIsMenuVisible,
246
+ menuItems: (close) =>
247
+ children?.map((option) =>
248
+ React.cloneElement(option, {
249
+ onClick: (value) => {
250
+ close();
251
+ option.props.onClick?.(value);
252
+ },
253
+ }),
254
+ ),
256
255
  },
257
256
  React.createElement(
258
257
  index_js_3.IconButton,
@@ -65,4 +65,4 @@ export { Anchor, Blockquote, Code, Kbd, KbdKeys, Text, } from './Typography/inde
65
65
  export { Stepper, WorkflowDiagram } from './Stepper/index.js';
66
66
  export type { StepProperties, StepperLocalization } from './Stepper/index.js';
67
67
  export { SearchBox } from './SearchBox/index.js';
68
- export { getUserColor, ColorValue, MiddleTextTruncation, LinkBox, LinkAction, Icon, Flex, VisuallyHidden, Divider, } from './utils/index.js';
68
+ export { getUserColor, ColorValue, MiddleTextTruncation, LinkBox, LinkAction, Icon, Flex, VisuallyHidden, Divider, Popover, } from './utils/index.js';
package/cjs/core/index.js CHANGED
@@ -102,7 +102,8 @@ exports.Tree =
102
102
  exports.Label =
103
103
  exports.InputGrid =
104
104
  void 0;
105
- exports.Divider =
105
+ exports.Popover =
106
+ exports.Divider =
106
107
  exports.VisuallyHidden =
107
108
  exports.Flex =
108
109
  exports.Icon =
@@ -907,3 +908,9 @@ Object.defineProperty(exports, 'Divider', {
907
908
  return index_js_58.Divider;
908
909
  },
909
910
  });
911
+ Object.defineProperty(exports, 'Popover', {
912
+ enumerable: true,
913
+ get: function () {
914
+ return index_js_58.Popover;
915
+ },
916
+ });
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- export type InputContainerProps<T extends React.ElementType = 'div'> = {
3
- as?: T;
2
+ import type { PolymorphicForwardRefComponent } from '../props.js';
3
+ export type InputContainerProps = {
4
4
  label?: React.ReactNode;
5
5
  disabled?: boolean;
6
6
  required?: boolean;
@@ -11,9 +11,9 @@ export type InputContainerProps<T extends React.ElementType = 'div'> = {
11
11
  statusMessage?: React.ReactNode;
12
12
  inputId?: string;
13
13
  labelId?: string;
14
- } & React.ComponentPropsWithoutRef<T>;
14
+ };
15
15
  /**
16
16
  * Input container to wrap inputs with label, and add optional message and icon.
17
17
  * @private
18
18
  */
19
- export declare const InputContainer: <T extends React.ElementType<any> = "div">(props: InputContainerProps<T>) => React.JSX.Element;
19
+ export declare const InputContainer: PolymorphicForwardRefComponent<"div", InputContainerProps>;
@@ -15,7 +15,7 @@ const index_js_2 = require('../../StatusMessage/index.js');
15
15
  * Input container to wrap inputs with label, and add optional message and icon.
16
16
  * @private
17
17
  */
18
- const InputContainer = (props) => {
18
+ exports.InputContainer = React.forwardRef((props, forwardedRef) => {
19
19
  const {
20
20
  label,
21
21
  disabled,
@@ -39,12 +39,17 @@ const InputContainer = (props) => {
39
39
  'data-iui-status': status,
40
40
  'data-iui-label-placement': isLabelInline ? 'inline' : undefined,
41
41
  style: style,
42
+ ref: forwardedRef,
42
43
  ...rest,
43
44
  },
44
45
  label &&
45
46
  React.createElement(
46
47
  index_js_1.Label,
48
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
49
+ // @ts-ignore
47
50
  {
51
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
52
+ // @ts-ignore
48
53
  as: inputId && props.as !== 'label' ? 'label' : 'div',
49
54
  required: required,
50
55
  disabled: disabled,
@@ -63,5 +68,4 @@ const InputContainer = (props) => {
63
68
  message,
64
69
  ),
65
70
  );
66
- };
67
- exports.InputContainer = InputContainer;
71
+ });
@@ -1,39 +1,125 @@
1
1
  import * as React from 'react';
2
- import type { TippyProps } from '@tippyjs/react';
3
- import type { Placement, Instance } from 'tippy.js';
4
- export type PopoverInstance = Instance;
5
- export type PopoverProps = {
2
+ import type { Placement } from '@floating-ui/react';
3
+ import type { PolymorphicForwardRefComponent } from '../index.js';
4
+ import type { PortalProps } from './Portal.js';
5
+ type PopoverOptions = {
6
+ /**
7
+ * Placement of the popover content.
8
+ * @default 'bottom-start'
9
+ */
10
+ placement?: Placement;
6
11
  /**
7
12
  * Controlled flag for whether the popover is visible.
8
13
  */
9
14
  visible?: boolean;
10
15
  /**
11
- * Determines the events that cause the popover to show.
12
- * Should not be used when `visible` is set.
13
- * @see [tippy.js trigger prop](https://atomiks.github.io/tippyjs/v6/all-props/#trigger)
16
+ * Callback invoked every time the popover visibility changes as a result
17
+ * of internal logic. Should be used alongside `visible` prop.
14
18
  */
15
- trigger?: string;
19
+ onVisibleChange?: (visible: boolean) => void;
16
20
  /**
17
- * Placement of the popover content.
18
- * @default 'bottom-start'
19
- * @see [tippy.js placement prop](https://atomiks.github.io/tippyjs/v6/all-props/#placement).
21
+ * If true, the popover will close when clicking outside it.
20
22
  */
21
- placement?: Placement;
22
- } & Omit<TippyProps, 'placement' | 'trigger' | 'visible'>;
23
- /**
24
- * Wrapper around [tippy.js](https://atomiks.github.io/tippyjs)
25
- * with pre-configured props and plugins (e.g. lazy mounting, focus, etc).
26
- * @private
27
- */
28
- export declare const Popover: React.ForwardRefExoticComponent<Omit<PopoverProps, "ref"> & React.RefAttributes<unknown>>;
29
- /**
30
- * Plugin to hide Popover when either Esc key is pressed,
31
- * or when the content inside is not tabbable and Tab key is pressed.
32
- */
33
- export declare const hideOnEscOrTab: {
34
- fn(instance: Instance): {
35
- onShow(): void;
36
- onHide(): void;
23
+ closeOnOutsideClick?: boolean;
24
+ /**
25
+ * Whether the popover should match the width of the trigger.
26
+ */
27
+ matchWidth?: boolean;
28
+ };
29
+ type PopoverInternalProps = {
30
+ /**
31
+ * autoUpdate options that recalculates position
32
+ * to ensure the floating element remains anchored
33
+ * to its reference element, such as when scrolling
34
+ * and resizing the screen
35
+ *
36
+ * https://floating-ui.com/docs/autoUpdate#options
37
+ */
38
+ autoUpdateOptions?: {
39
+ ancestorScroll?: boolean;
40
+ ancestorResize?: boolean;
41
+ elementResize?: boolean;
42
+ /**
43
+ * Use this if you want popover to follow moving trigger element
44
+ */
45
+ animationFrame?: boolean;
46
+ layoutShift?: boolean;
47
+ };
48
+ /**
49
+ * Middleware options.
50
+ *
51
+ * @see https://floating-ui.com/docs/offset
52
+ */
53
+ middleware?: {
54
+ offset?: number;
55
+ flip?: boolean;
56
+ shift?: boolean;
57
+ autoPlacement?: boolean;
58
+ hide?: boolean;
59
+ inline?: boolean;
37
60
  };
61
+ /**
62
+ * By default, the popover will only open on click.
63
+ * `hover` and `focus` can be manually specified as triggers.
64
+ */
65
+ trigger?: Partial<Record<'hover' | 'click' | 'focus', boolean>>;
66
+ role?: 'dialog' | 'menu' | 'listbox';
67
+ };
68
+ export declare const usePopover: (options: PopoverOptions & PopoverInternalProps) => {
69
+ placement: Placement;
70
+ strategy: import("@floating-ui/utils").Strategy;
71
+ middlewareData: import("@floating-ui/core").MiddlewareData;
72
+ x: number;
73
+ y: number;
74
+ isPositioned: boolean;
75
+ update: () => void;
76
+ floatingStyles: React.CSSProperties;
77
+ refs: {
78
+ reference: React.MutableRefObject<import("@floating-ui/react-dom").ReferenceType | null>;
79
+ floating: React.MutableRefObject<HTMLElement | null>;
80
+ setReference: (node: import("@floating-ui/react-dom").ReferenceType | null) => void;
81
+ setFloating: (node: HTMLElement | null) => void;
82
+ } & import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
83
+ elements: {
84
+ reference: import("@floating-ui/react-dom").ReferenceType | null; /**
85
+ * Middleware options.
86
+ *
87
+ * @see https://floating-ui.com/docs/offset
88
+ */
89
+ floating: HTMLElement | null;
90
+ } & import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
91
+ context: {
92
+ x: number;
93
+ y: number;
94
+ placement: Placement;
95
+ strategy: import("@floating-ui/utils").Strategy;
96
+ middlewareData: import("@floating-ui/core").MiddlewareData;
97
+ isPositioned: boolean;
98
+ update: () => void;
99
+ floatingStyles: React.CSSProperties;
100
+ open: boolean;
101
+ onOpenChange: (open: boolean, event?: Event | undefined) => void;
102
+ events: import("@floating-ui/react").FloatingEvents;
103
+ dataRef: React.MutableRefObject<import("@floating-ui/react").ContextData>;
104
+ nodeId: string | undefined;
105
+ floatingId: string;
106
+ refs: import("@floating-ui/react").ExtendedRefs<import("@floating-ui/react").ReferenceType>;
107
+ elements: import("@floating-ui/react").ExtendedElements<import("@floating-ui/react").ReferenceType>;
108
+ };
109
+ getFloatingProps: (userProps?: React.HTMLProps<HTMLElement>) => Record<string, unknown>;
110
+ getReferenceProps: (userProps?: React.HTMLProps<Element> | undefined) => Record<string, unknown>;
111
+ getItemProps: (userProps?: React.HTMLProps<HTMLElement> | undefined) => Record<string, unknown>;
112
+ open: boolean | undefined;
113
+ onOpenChange: React.Dispatch<React.SetStateAction<boolean | undefined>>;
38
114
  };
115
+ type PopoverPublicProps = {
116
+ content?: React.ReactNode;
117
+ children?: React.ReactNode;
118
+ applyBackground?: boolean;
119
+ } & PortalProps & PopoverOptions;
120
+ /**
121
+ * A utility component to help with positioning of floating content.
122
+ * Built on top of [`floating-ui`](https://floating-ui.com/)
123
+ */
124
+ export declare const Popover: PolymorphicForwardRefComponent<"div", PopoverPublicProps>;
39
125
  export default Popover;