@box/blueprint-web 14.40.0 → 14.41.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.
@@ -1,4 +1,4 @@
1
1
  import '../index.css';
2
- var styles = {"avatar":"bp_avatar_module_avatar--7018b","xsmall":"bp_avatar_module_xsmall--7018b","length-1":"bp_avatar_module_length-1--7018b","text":"bp_avatar_module_text--7018b","length-2":"bp_avatar_module_length-2--7018b","small":"bp_avatar_module_small--7018b","medium":"bp_avatar_module_medium--7018b","large":"bp_avatar_module_large--7018b","length-3":"bp_avatar_module_length-3--7018b","length-4":"bp_avatar_module_length-4--7018b","xlarge":"bp_avatar_module_xlarge--7018b","xxlarge":"bp_avatar_module_xxlarge--7018b","badge":"bp_avatar_module_badge--7018b","image":"bp_avatar_module_image--7018b","loading":"bp_avatar_module_loading--7018b","anonymousAvatar":"bp_avatar_module_anonymousAvatar--7018b","iconContainer":"bp_avatar_module_iconContainer--7018b"};
2
+ var styles = {"avatar":"bp_avatar_module_avatar--da0f5","xsmall":"bp_avatar_module_xsmall--da0f5","length-1":"bp_avatar_module_length-1--da0f5","text":"bp_avatar_module_text--da0f5","length-2":"bp_avatar_module_length-2--da0f5","small":"bp_avatar_module_small--da0f5","medium":"bp_avatar_module_medium--da0f5","large":"bp_avatar_module_large--da0f5","length-3":"bp_avatar_module_length-3--da0f5","length-4":"bp_avatar_module_length-4--da0f5","xlarge":"bp_avatar_module_xlarge--da0f5","xxlarge":"bp_avatar_module_xxlarge--da0f5","badge":"bp_avatar_module_badge--da0f5","image":"bp_avatar_module_image--da0f5","loading":"bp_avatar_module_loading--da0f5","anonymousAvatar":"bp_avatar_module_anonymousAvatar--da0f5","iconContainer":"bp_avatar_module_iconContainer--da0f5"};
3
3
 
4
4
  export { styles as default };
@@ -1,18 +1,21 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { SelectItemCheck, SelectItem, ComboboxItem, useComboboxStore, useSelectStore, PopoverAnchor, Combobox as Combobox$1, ComboboxCancel, SelectList, ComboboxPopover } from '@ariakit/react';
3
3
  import { SelectRenderer } from '@ariakit/react-core/select/select-renderer';
4
- import { Checkmark, XMark as XMark$1 } from '@box/blueprint-web-assets/icons/Fill';
5
- import { XMark } from '@box/blueprint-web-assets/icons/Medium';
6
- import { bpIconIconOnLight, IconIconOnLight } from '@box/blueprint-web-assets/tokens/tokens';
4
+ import { Checkmark, AlertBadge, XMark as XMark$1 } from '@box/blueprint-web-assets/icons/Fill';
5
+ import { AlertCircle, XMark } from '@box/blueprint-web-assets/icons/Medium';
6
+ import { bpIconIconOnLight, IconIconOnLight, IconIconErrorOnLight } from '@box/blueprint-web-assets/tokens/tokens';
7
7
  import clsx from 'clsx';
8
8
  import React__default, { forwardRef, useMemo, useRef, useCallback, useEffect } from 'react';
9
9
  import { useBlueprintModernization } from '../blueprint-modernization-context/useBlueprintModernization.js';
10
+ import { Focusable } from '../focusable/focusable.js';
10
11
  import { InputChip } from '../input-chip/input-chip.js';
11
12
  import { LoadingIndicator } from '../loading-indicator/loading-indicator.js';
12
13
  import { IconButton } from '../primitives/icon-button/icon-button.js';
13
14
  import { InlineError } from '../primitives/inline-error/inline-error.js';
14
15
  import { TextArea } from '../text-area/text-area.js';
16
+ import { Tooltip } from '../tooltip/tooltip.js';
15
17
  import { useLabelable } from '../util-components/labelable/useLabelable.js';
18
+ import { VisuallyHidden } from '../visually-hidden/visually-hidden.js';
16
19
  import { composeEventHandlers } from '../utils/composeEventHandlers.js';
17
20
  import { useForkRef } from '../utils/useForkRef.js';
18
21
  import { useUniqueId } from '../utils/useUniqueId.js';
@@ -46,6 +49,7 @@ const RootInner = ({
46
49
  className,
47
50
  popoverClassName,
48
51
  error,
52
+ errorVariant = 'default',
49
53
  hideLabel = false,
50
54
  label,
51
55
  defaultOpen = false,
@@ -335,6 +339,8 @@ const RootInner = ({
335
339
  const showChipsGroup = Array.isArray(selectedValue) && selectedValue.length > 0;
336
340
  const showComboboxCancelButton = clearButtonAriaLabel && (inputValue.length > 0 || (Array.isArray(selectedValue) ? selectedValue.length > 0 : !!selectedValue));
337
341
  const showSingleSelectChip = displaySingleSelectionAsChip && !Array.isArray(selectedValue) && !!selectedValue;
342
+ const showInlineError = errorVariant === 'inline' && hasError;
343
+ const InlineErrorIcon = enableModernizedComponents ? AlertCircle : AlertBadge;
338
344
  const Label = useLabelable(label, comboboxId, required);
339
345
  const inlineErrorId = useUniqueId('inline-error-');
340
346
  const ariaDescribedBy = clsx(rest['aria-describedby'], {
@@ -361,7 +367,8 @@ const RootInner = ({
361
367
  className: clsx(styles.comboboxContainer, {
362
368
  [styles.error]: hasError,
363
369
  [styles.withChips]: showChipsGroup || showSingleSelectChip,
364
- [styles.withComboboxButtons]: showComboboxCancelButton || Boolean(endComboboxIcon)
370
+ [styles.withComboboxButtons]: showComboboxCancelButton || Boolean(endComboboxIcon) || showInlineError,
371
+ [styles.withInlineErrorAndEndButton]: showInlineError && (showComboboxCancelButton || Boolean(endComboboxIcon))
365
372
  }),
366
373
  onClick: handleFocusInputOnEvent,
367
374
  "data-testid": "combobox-container",
@@ -402,9 +409,26 @@ const RootInner = ({
402
409
  onKeyDown: handleKeyDown,
403
410
  required: required,
404
411
  store: comboboxStore
405
- }), jsx("div", {
412
+ }), jsxs("div", {
406
413
  className: styles.comboboxButtons,
407
- children: showComboboxCancelButton ? jsx(ComboboxCancel, {
414
+ children: [showInlineError && jsxs(Fragment, {
415
+ children: [jsx(Tooltip, {
416
+ content: error,
417
+ side: "top",
418
+ variant: "error",
419
+ children: jsx(Focusable, {
420
+ "aria-labelledby": inlineErrorId,
421
+ children: jsx(InlineErrorIcon, {
422
+ className: styles.inlineErrorIcon,
423
+ color: IconIconErrorOnLight,
424
+ "data-testid": enableModernizedComponents ? 'combobox-inline-error-icon-modern' : 'combobox-inline-error-icon-legacy'
425
+ })
426
+ })
427
+ }), jsx(VisuallyHidden, {
428
+ id: inlineErrorId,
429
+ children: error
430
+ })]
431
+ }), showComboboxCancelButton ? jsx(ComboboxCancel, {
408
432
  onClick: resetSelectedValue,
409
433
  // eslint-disable-next-line react/jsx-no-bind
410
434
  render: cancelProps => jsx(IconButton, {
@@ -414,12 +438,12 @@ const RootInner = ({
414
438
  size: "x-small"
415
439
  }),
416
440
  store: comboboxStore
417
- }) : endComboboxIcon
441
+ }) : endComboboxIcon]
418
442
  })]
419
443
  })]
420
444
  })
421
445
  })
422
- }), jsx(InlineError, {
446
+ }), errorVariant === 'default' && jsx(InlineError, {
423
447
  className: styles.inlineError,
424
448
  id: inlineErrorId,
425
449
  children: error
@@ -1,4 +1,4 @@
1
1
  import '../index.css';
2
- var styles = {"container":"bp_combobox_module_container--c4fe7","label":"bp_combobox_module_label--c4fe7","textInput":"bp_combobox_module_textInput--c4fe7","popover":"bp_combobox_module_popover--c4fe7","disabled":"bp_combobox_module_disabled--c4fe7","hiddenLabel":"bp_combobox_module_hiddenLabel--c4fe7","comboboxContainer":"bp_combobox_module_comboboxContainer--c4fe7","comboboxContainerInner":"bp_combobox_module_comboboxContainerInner--c4fe7","withChips":"bp_combobox_module_withChips--c4fe7","error":"bp_combobox_module_error--c4fe7","withComboboxButtons":"bp_combobox_module_withComboboxButtons--c4fe7","textInputWrapper":"bp_combobox_module_textInputWrapper--c4fe7","comboboxButtons":"bp_combobox_module_comboboxButtons--c4fe7","inlineError":"bp_combobox_module_inlineError--c4fe7","popoverInner":"bp_combobox_module_popoverInner--c4fe7","option":"bp_combobox_module_option--c4fe7","indicator":"bp_combobox_module_indicator--c4fe7","indicatorIcon":"bp_combobox_module_indicatorIcon--c4fe7","optionWithIndicator":"bp_combobox_module_optionWithIndicator--c4fe7","loadingIndicator":"bp_combobox_module_loadingIndicator--c4fe7"};
2
+ var styles = {"container":"bp_combobox_module_container--61e5e","label":"bp_combobox_module_label--61e5e","textInput":"bp_combobox_module_textInput--61e5e","popover":"bp_combobox_module_popover--61e5e","disabled":"bp_combobox_module_disabled--61e5e","hiddenLabel":"bp_combobox_module_hiddenLabel--61e5e","comboboxContainer":"bp_combobox_module_comboboxContainer--61e5e","comboboxContainerInner":"bp_combobox_module_comboboxContainerInner--61e5e","withChips":"bp_combobox_module_withChips--61e5e","error":"bp_combobox_module_error--61e5e","withComboboxButtons":"bp_combobox_module_withComboboxButtons--61e5e","withInlineErrorAndEndButton":"bp_combobox_module_withInlineErrorAndEndButton--61e5e","textInputWrapper":"bp_combobox_module_textInputWrapper--61e5e","comboboxButtons":"bp_combobox_module_comboboxButtons--61e5e","inlineErrorIcon":"bp_combobox_module_inlineErrorIcon--61e5e","inlineError":"bp_combobox_module_inlineError--61e5e","popoverInner":"bp_combobox_module_popoverInner--61e5e","option":"bp_combobox_module_option--61e5e","indicator":"bp_combobox_module_indicator--61e5e","indicatorIcon":"bp_combobox_module_indicatorIcon--61e5e","optionWithIndicator":"bp_combobox_module_optionWithIndicator--61e5e","loadingIndicator":"bp_combobox_module_loadingIndicator--61e5e"};
3
3
 
4
4
  export { styles as default };
@@ -2,6 +2,7 @@ import { type ComboboxProps as AriakitComboboxProps, type ComboboxPopoverProps }
2
2
  import { type SelectItemProps } from '@ariakit/react-core/select/select-item';
3
3
  import { type SelectRendererProps } from '@ariakit/react-core/select/select-renderer';
4
4
  import { type InputChipProps } from '../input-chip/types';
5
+ import { type ErrorVariant } from '../primitives/base-text-input/types';
5
6
  import { type TextAreaProps } from '../text-area/types';
6
7
  import { type Labelable } from '../util-components/labelable/types';
7
8
  export type OptionValue = {
@@ -178,6 +179,14 @@ export interface ComboboxBaseProps<Multiple extends boolean, FreeInput extends b
178
179
  * The content of the error message
179
180
  */
180
181
  error?: React.ReactNode;
182
+ /**
183
+ * How the error message is displayed.
184
+ * - `default`: renders an inline error message below the combobox.
185
+ * - `inline`: renders an always-visible error icon inside the combobox; the error message shows in a tooltip on hover/focus of the icon.
186
+ *
187
+ * @default 'default'
188
+ */
189
+ errorVariant?: ErrorVariant;
181
190
  /**
182
191
  * The DOM element where the Combobox should be portal-ed into. If not provided, the Combobox will be appended to the document body.
183
192
  */