@box/blueprint-web 7.18.3 → 7.19.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.
@@ -43,6 +43,7 @@ const RootInner = ({
43
43
  defaultOpen = false,
44
44
  open,
45
45
  onOpenChange,
46
+ onFocus,
46
47
  defaultInputValue = '',
47
48
  inputValue: inputValueProp,
48
49
  onInputValueChange,
@@ -64,12 +65,18 @@ const RootInner = ({
64
65
  hideSelectedOptions = false,
65
66
  unmountOnHide = false,
66
67
  experimentalVirtualization = false,
68
+ getPopoverRef,
69
+ focusLoop,
67
70
  ...comboboxProps
68
71
  } = rest;
69
72
  const isInput = useMemo(() => as === 'input', [as]);
70
73
  const inputRef = useRef(null);
71
- const popoverRef = useRef(null);
72
74
  const comboboxId = useUniqueId('combobox-');
75
+ const popoverRef = useRef(null);
76
+ const popoverRefCallback = useCallback(node => {
77
+ popoverRef.current = node;
78
+ getPopoverRef?.(node);
79
+ }, [getPopoverRef]);
73
80
  const hasError = !!error && !disabled;
74
81
  const comboboxStore = useComboboxStore({
75
82
  // Input state
@@ -81,7 +88,8 @@ const RootInner = ({
81
88
  open: open && !disabled,
82
89
  setOpen: onOpenChange,
83
90
  includesBaseElement: true,
84
- virtualFocus: false
91
+ virtualFocus: false,
92
+ focusLoop
85
93
  });
86
94
  const {
87
95
  setValue: setInputValue,
@@ -199,6 +207,9 @@ const RootInner = ({
199
207
  },
200
208
  // eslint-disable-next-line react-hooks/exhaustive-deps
201
209
  [clearOnBlur, isOpen, selectedValue, setInputValue]);
210
+ const handleOnFocus = useCallback(() => {
211
+ onFocus?.();
212
+ }, [onFocus]);
202
213
  const removeInputChip = id => {
203
214
  // For multi-select variant only
204
215
  selectStore.setValue(prev => {
@@ -253,6 +264,7 @@ const RootInner = ({
253
264
  disabled: disabled,
254
265
  id: comboboxId,
255
266
  onBlur: handleOnBlur,
267
+ onFocus: handleOnFocus,
256
268
  onKeyDown: handleKeyDown,
257
269
  required: required,
258
270
  store: comboboxStore
@@ -277,6 +289,7 @@ const RootInner = ({
277
289
  hideLabel: hideLabel,
278
290
  label: label,
279
291
  onBlur: handleOnBlur,
292
+ onFocus: handleOnFocus,
280
293
  onKeyDown: handleKeyDown,
281
294
  required: required
282
295
  }),
@@ -297,7 +310,7 @@ const RootInner = ({
297
310
  [styles.disabled]: disabled
298
311
  }, className),
299
312
  children: [inputComponent, showLoading || filteredOptions.length > 0 || filteredOptions.length <= 0 && noResultMessage ? jsx(ComboboxPopover, {
300
- ref: popoverRef,
313
+ ref: popoverRefCallback,
301
314
  "aria-labelledby": comboboxId,
302
315
  className: styles.popover,
303
316
  fitViewport: true,
@@ -175,6 +175,19 @@ export interface ComboboxBaseProps<Multiple extends boolean, FreeInput extends b
175
175
  * @default false
176
176
  */
177
177
  experimentalVirtualization?: boolean;
178
+ /**
179
+ * Callback ref when popover is mounted or unmounted
180
+ */
181
+ getPopoverRef?: (node: HTMLDivElement | null) => void;
182
+ /**
183
+ * Determines how the focus behaves when the user reaches the end of the combobox. Can be useful to turn off when implementing infinite scrolling.
184
+ * @default true
185
+ */
186
+ focusLoop?: boolean;
187
+ /**
188
+ * Callback used when combobox input/textarea is focused
189
+ */
190
+ onFocus?: () => void;
178
191
  }
179
192
  export type ComboboxTextArea = Pick<TextAreaProps, 'maxRows' | 'minRows' | 'maxLength'> & {
180
193
  as: 'textarea';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "7.18.3",
3
+ "version": "7.19.1",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "publishConfig": {
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@ariakit/react": "0.4.5",
29
29
  "@ariakit/react-core": "0.4.5",
30
- "@box/blueprint-web-assets": "^4.19.0",
30
+ "@box/blueprint-web-assets": "^4.19.1",
31
31
  "@internationalized/date": "^3.5.4",
32
32
  "@radix-ui/react-accordion": "1.1.2",
33
33
  "@radix-ui/react-checkbox": "1.0.4",
@@ -66,7 +66,7 @@
66
66
  "react-stately": "^3.31.1",
67
67
  "tsx": "^4.16.5"
68
68
  },
69
- "gitHead": "12b5f781586458fc2f5889c85af939cd19bce66b",
69
+ "gitHead": "ecbf610b70f2c1c82d64036d7af6e0490f4c7010",
70
70
  "module": "lib-esm/index.js",
71
71
  "main": "lib-esm/index.js",
72
72
  "exports": {