@cimpress-ui/react 1.26.0 → 1.27.0

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 (39) hide show
  1. package/dist/commonjs/components/combo-box/combo-box.d.ts +28 -7
  2. package/dist/commonjs/components/combo-box/combo-box.d.ts.map +1 -1
  3. package/dist/commonjs/components/combo-box/combo-box.js +9 -7
  4. package/dist/commonjs/components/combo-box/combo-box.js.map +1 -1
  5. package/dist/commonjs/components/select/select.d.ts +42 -31
  6. package/dist/commonjs/components/select/select.d.ts.map +1 -1
  7. package/dist/commonjs/components/select/select.js +27 -39
  8. package/dist/commonjs/components/select/select.js.map +1 -1
  9. package/dist/commonjs/components/tag-field/tag-field.d.ts +11 -2
  10. package/dist/commonjs/components/tag-field/tag-field.d.ts.map +1 -1
  11. package/dist/commonjs/components/tag-field/tag-field.js +11 -2
  12. package/dist/commonjs/components/tag-field/tag-field.js.map +1 -1
  13. package/dist/commonjs/i18n/messages/en-US.d.ts.map +1 -1
  14. package/dist/commonjs/i18n/messages/en-US.js +7 -0
  15. package/dist/commonjs/i18n/messages/en-US.js.map +1 -1
  16. package/dist/commonjs/i18n/messages/types.d.ts +12 -0
  17. package/dist/commonjs/i18n/messages/types.d.ts.map +1 -1
  18. package/dist/commonjs/i18n/messages/types.js.map +1 -1
  19. package/dist/esm/components/combo-box/combo-box.d.ts +28 -7
  20. package/dist/esm/components/combo-box/combo-box.d.ts.map +1 -1
  21. package/dist/esm/components/combo-box/combo-box.js +9 -7
  22. package/dist/esm/components/combo-box/combo-box.js.map +1 -1
  23. package/dist/esm/components/select/select.d.ts +42 -31
  24. package/dist/esm/components/select/select.d.ts.map +1 -1
  25. package/dist/esm/components/select/select.js +29 -41
  26. package/dist/esm/components/select/select.js.map +1 -1
  27. package/dist/esm/components/tag-field/tag-field.d.ts +11 -2
  28. package/dist/esm/components/tag-field/tag-field.d.ts.map +1 -1
  29. package/dist/esm/components/tag-field/tag-field.js +11 -2
  30. package/dist/esm/components/tag-field/tag-field.js.map +1 -1
  31. package/dist/esm/i18n/messages/en-US.d.ts.map +1 -1
  32. package/dist/esm/i18n/messages/en-US.js +7 -0
  33. package/dist/esm/i18n/messages/en-US.js.map +1 -1
  34. package/dist/esm/i18n/messages/types.d.ts +12 -0
  35. package/dist/esm/i18n/messages/types.d.ts.map +1 -1
  36. package/dist/esm/i18n/messages/types.js.map +1 -1
  37. package/dist-styles/core.css +1 -1
  38. package/dist-styles/styles.css +1 -1
  39. package/package.json +1 -1
@@ -3,18 +3,40 @@ import { type ComboBoxProps as RACComboBoxProps, type ListBoxItemProps as RACLis
3
3
  import type { ApiProps, AsyncItemLoadingProps, CollectionItem, CollectionProps, CommonProps, FieldWithPlaceholderProps, Key, StringLikeChildren } from '../types.js';
4
4
  /** Represents the state of the `ComboBox` component for validation purposes. */
5
5
  export interface ComboBoxValidationValue {
6
- /** The selected key in the ComboBox. */
7
- selectedKey: Key | null;
8
- /** The value of the ComboBox input. */
6
+ /** The selected key in the combo box. */
7
+ value: Key | null;
8
+ /** The value of the combo box input. */
9
9
  inputValue: string;
10
+ /**
11
+ * The selected key in the combo box.
12
+ * @deprecated Use `value` instead.
13
+ */
14
+ selectedKey: Key | null;
10
15
  }
11
16
  export interface ComboBoxProps<T extends CollectionItem = CollectionItem> extends CommonProps, FieldWithPlaceholderProps<ComboBoxValidationValue>, CollectionProps<T>, AsyncItemLoadingProps, ApiProps<ComboBoxApi>, Pick<RACComboBoxProps<T>, 'isDisabled' | 'isRequired' | 'isInvalid' | 'isReadOnly' | 'inputValue' | 'defaultInputValue' | 'autoFocus' | 'onInputChange' | 'onFocus' | 'onBlur' | 'onOpenChange'> {
12
- /** The currently selected key in the collection (controlled). */
17
+ /** The current value (controlled). */
18
+ value?: Key | null;
19
+ /** The initial value (uncontrolled). */
20
+ defaultValue?: Key;
21
+ /** Handler that is called when the value changes. */
22
+ onChange?: (key: Key | null) => void;
23
+ /**
24
+ * The currently selected key in the collection (controlled).
25
+ * @deprecated Use `value` instead.
26
+ */
13
27
  selectedKey?: Key | null;
14
- /** The initial selected key in the collection (uncontrolled). */
28
+ /**
29
+ * The initial selected key in the collection (uncontrolled).
30
+ * @deprecated Use `defaultValue` instead.
31
+ */
15
32
  defaultSelectedKey?: Key;
16
- /** Handler that is called when the selection changes. */
33
+ /**
34
+ * Handler that is called when the selection changes.
35
+ * @deprecated Use `onChange` instead.
36
+ */
17
37
  onSelectionChange?: (key: Key | null) => void;
38
+ /** Whether to display a clear button to clear the selection. */
39
+ isClearable?: boolean;
18
40
  /**
19
41
  * Whether the list of options should be virtualized. Use this as a performance optimization for large lists.
20
42
  * @default false
@@ -22,7 +44,6 @@ export interface ComboBoxProps<T extends CollectionItem = CollectionItem> extend
22
44
  isVirtualized?: boolean;
23
45
  /** Handler that is called when the list of items is scrolled. */
24
46
  onScroll?: UIEventHandler<HTMLDivElement>;
25
- UNSTABLE_isClearable?: boolean;
26
47
  }
27
48
  /** The imperative API exposed by the `ComboBox` component. */
28
49
  export interface ComboBoxApi {
@@ -1 +1 @@
1
- {"version":3,"file":"combo-box.d.ts","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,cAAc,EAIpB,MAAM,OAAO,CAAC;AAEf,OAAO,EAeL,KAAK,aAAa,IAAI,gBAAgB,EACtC,KAAK,gBAAgB,IAAI,mBAAmB,EAE7C,MAAM,uBAAuB,CAAC;AAW/B,OAAO,KAAK,EACV,QAAQ,EACR,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,WAAW,EACX,yBAAyB,EACzB,GAAG,EACH,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAWrB,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,wCAAwC;IACxC,WAAW,EAAE,GAAG,GAAG,IAAI,CAAC;IACxB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa,CAAC,CAAC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;CAC9B;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,CAAC,SAAS,cAAc,EAAE,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,2CAiBlG;yBAjBe,YAAY;;;AAqB5B,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IACxF,6EAA6E;IAC7E,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,CAAC,SAAS,cAAc,EAAE,EACxD,KAAK,EACL,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACT,EAAE,oBAAoB,CAAC,CAAC,CAAC,2CAezB;yBApBe,eAAe"}
1
+ {"version":3,"file":"combo-box.d.ts","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,cAAc,EAIpB,MAAM,OAAO,CAAC;AAEf,OAAO,EAeL,KAAK,aAAa,IAAI,gBAAgB,EACtC,KAAK,gBAAgB,IAAI,mBAAmB,EAE7C,MAAM,uBAAuB,CAAC;AAW/B,OAAO,KAAK,EACV,QAAQ,EACR,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,WAAW,EACX,yBAAyB,EACzB,GAAG,EACH,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAWrB,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,yCAAyC;IACzC,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;IAClB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,WAAW,EAAE,GAAG,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,CACtE,SACE,WAAW,EACX,yBAAyB,CAAC,uBAAuB,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AAC,EACtB,YAAY,GAAG,cAAc,GAAG,YAAY,CAC7C;IACC,0EAA0E;IAC1E,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,2CAA2C;IAC3C,QAAQ,EAAE,kBAAkB,CAAC;CAC9B;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,CAAC,SAAS,cAAc,EAAE,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,2CAiBlG;yBAjBe,YAAY;;;AAqB5B,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IACxF,6EAA6E;IAC7E,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,0DAA0D;AAC1D,wBAAgB,eAAe,CAAC,CAAC,SAAS,cAAc,EAAE,EACxD,KAAK,EACL,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACT,EAAE,oBAAoB,CAAC,CAAC,CAAC,2CAezB;yBApBe,eAAe"}
@@ -30,7 +30,7 @@ const VIRTUAL_LAYOUT_OPTIONS = {
30
30
  padding: 0,
31
31
  gap: 0,
32
32
  };
33
- function ComboBox({ label, description, error, items, children, placeholder, UNSAFE_className, UNSAFE_style, isReadOnly, onScroll, isVirtualized = false, UNSTABLE_isLoading: isLoading, UNSTABLE_onLoadMore: onLoadMore, UNSTABLE_isClearable: isClearable = false, apiRef, selectedKey, defaultSelectedKey, onSelectionChange, validate, ...props }, ref) {
33
+ function ComboBox({ label, description, error, items, children, placeholder, UNSAFE_className, UNSAFE_style, isReadOnly, onScroll, isVirtualized = false, isClearable = false, UNSTABLE_isLoading: isLoading, UNSTABLE_onLoadMore: onLoadMore, apiRef, value, defaultValue, onChange, selectedKey, defaultSelectedKey, onSelectionChange, validate, ...props }, ref) {
34
34
  const inputRef = (0, react_1.useRef)(null);
35
35
  const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;
36
36
  (0, use_production_warning_js_1.useProductionWarning)(() => {
@@ -47,11 +47,11 @@ function ComboBox({ label, description, error, items, children, placeholder, UNS
47
47
  }), []);
48
48
  const isFieldClearable = isClearable && !props.isDisabled && !isReadOnly;
49
49
  const listBox = ((0, jsx_runtime_1.jsx)(ComboBoxList, { items: items, isLoading: isLoading, onLoadMore: onLoadMore, onScroll: onScroll, children: children }));
50
- return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ComboBox, { ...props, ref: ref, className: (0, clsx_1.default)('cim-combo-box', UNSAFE_className), style: UNSAFE_style, selectionMode: "single", value: selectedKey, defaultValue: defaultSelectedKey, onChange: onSelectionChange, menuTrigger: "focus", isReadOnly: isReadOnly, "data-readonly": isReadOnly ? true : undefined, validate: validate
50
+ return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ComboBox, { ...props, ref: ref, className: (0, clsx_1.default)('cim-combo-box', UNSAFE_className), style: UNSAFE_style, selectionMode: "single", value: value, defaultValue: defaultValue, onChange: onChange, selectedKey: selectedKey, defaultSelectedKey: defaultSelectedKey, onSelectionChange: onSelectionChange, menuTrigger: "focus", isReadOnly: isReadOnly, "data-readonly": isReadOnly ? true : undefined, validate: validate
51
51
  ? ({ inputValue, value }) => {
52
- return validate({ inputValue, selectedKey: value });
52
+ return validate({ inputValue, value, selectedKey: value });
53
53
  }
54
- : undefined, children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: props.isRequired, isDisabled: props.isDisabled, children: label }), (0, jsx_runtime_1.jsxs)(react_aria_components_1.Group, { className: "cim-combo-box-input-group", children: [(0, jsx_runtime_1.jsx)(ComboBoxInput, { inputRef: inputRef, isReadOnly: isReadOnly, placeholder: placeholder, isClearable: isFieldClearable }), isFieldClearable && (0, jsx_runtime_1.jsx)(ComboBoxClearButton, {}), (0, jsx_runtime_1.jsx)(react_aria_components_1.Button, { className: "cim-combo-box-button", children: (0, jsx_runtime_1.jsx)(index_js_2.IconChevronDown, {}) })] }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: error }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description }), (0, jsx_runtime_1.jsx)(collapsible_list_js_1.CollapsibleList, { offset: 5, maxHeight: 315, children: isVirtualized ? ((0, jsx_runtime_1.jsx)(react_aria_components_1.Virtualizer, { layout: react_aria_components_1.ListLayout, layoutOptions: VIRTUAL_LAYOUT_OPTIONS, children: listBox })) : (listBox) })] }));
54
+ : undefined, children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: props.isRequired, isDisabled: props.isDisabled, children: label }), (0, jsx_runtime_1.jsxs)(react_aria_components_1.Group, { className: "cim-combo-box-input-group", children: [(0, jsx_runtime_1.jsx)(ComboBoxInput, { inputRef: inputRef, isReadOnly: isReadOnly, placeholder: placeholder, isClearable: isFieldClearable }), isFieldClearable && (0, jsx_runtime_1.jsx)(ComboBoxClearButton, { onClear: () => inputRef.current?.focus() }), (0, jsx_runtime_1.jsx)(react_aria_components_1.Button, { className: "cim-combo-box-button", children: (0, jsx_runtime_1.jsx)(index_js_2.IconChevronDown, {}) })] }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: error }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description }), (0, jsx_runtime_1.jsx)(collapsible_list_js_1.CollapsibleList, { offset: 5, maxHeight: 315, children: isVirtualized ? ((0, jsx_runtime_1.jsx)(react_aria_components_1.Virtualizer, { layout: react_aria_components_1.ListLayout, layoutOptions: VIRTUAL_LAYOUT_OPTIONS, children: listBox })) : (listBox) })] }));
55
55
  }
56
56
  /**
57
57
  * Allows users to filter a collapsible list and select one item from it.
@@ -60,15 +60,17 @@ function ComboBox({ label, description, error, items, children, placeholder, UNS
60
60
  */
61
61
  const _ComboBox = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(ComboBox), 'ComboBox');
62
62
  exports.ComboBox = _ComboBox;
63
- function ComboBoxClearButton() {
63
+ function ComboBoxClearButton({ onClear }) {
64
64
  const comboBoxState = (0, react_1.useContext)(react_aria_components_1.ComboBoxStateContext);
65
+ const selectMessages = (0, index_js_1.useLocalizedMessages)('select');
65
66
  const inputValue = comboBoxState?.inputValue;
66
67
  if (!comboBoxState || inputValue === '') {
67
68
  return null;
68
69
  }
69
70
  return ((0, jsx_runtime_1.jsx)(x_button_js_1.XButton, { onPress: () => {
70
- comboBoxState?.setValue(null);
71
- }, iconType: "circled", "aria-label": "Clear selection",
71
+ comboBoxState.setValue(null);
72
+ onClear?.();
73
+ }, iconType: "circled", "aria-label": selectMessages.format('clearSelection'),
72
74
  // Prevent this button from acting as a trigger for opening/closing the ComboBox
73
75
  slot: null, excludeFromTabOrder: true }));
74
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"combo-box.js","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAwUb,oCAiBC;AAYD,0CAoBC;;AAvXD,gDAAwB;AACxB,iCAOe;AACf,2CAA8C;AAC9C,iEAkB+B;AAC/B,yDAAkD;AAClD,kDAA2D;AAC3D,mDAAsE;AACtE,mEAA4D;AAC5D,qFAA6E;AAC7E,mEAA2D;AAC3D,0FAAmF;AACnF,wEAA4G;AAC5G,kEAA2D;AAC3D,sDAAgD;AAWhD,qDAAmD;AAEnD,MAAM,sBAAsB,GAAyB;IACnD,kBAAkB,EAAE,EAAE;IACtB,sBAAsB,EAAE,EAAE;IAC1B,YAAY,EAAE,EAAE;IAChB,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,CAAC;CACP,CAAC;AAuDF,SAAS,QAAQ,CACf,EACE,KAAK,EACL,WAAW,EACX,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,aAAa,GAAG,KAAK,EACrB,kBAAkB,EAAE,S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n\nimport clsx from 'clsx';\nimport {\n type ForwardedRef,\n type MutableRefObject,\n type UIEventHandler,\n useContext,\n useImperativeHandle,\n useRef,\n} from 'react';\nimport { usePreventScroll } from 'react-aria';\nimport {\n Button as RACButton,\n Collection as RACCollection,\n ComboBox as RACComboBox,\n ComboBoxStateContext as RACComboBoxStateContext,\n Group as RACGroup,\n Header as RACHeader,\n Input as RACInput,\n ListBox as RACListBox,\n ListBoxLoadMoreItem as RACListBoxLoadMoreItem,\n ListBoxItem as RACListBoxItem,\n ListBoxSection as RACListBoxSection,\n ListLayout as RACListLayout,\n type ListLayoutOptions as RACListLayoutOptions,\n Text as RACText,\n type ComboBoxProps as RACComboBoxProps,\n type ListBoxItemProps as RACListBoxItemProps,\n Virtualizer as RACVirtualizer,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { IconCheckBold, IconChevronDown } from '../../icons/index.js';\nimport { isProduction } from '../../utils/is-production.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { CollapsibleList } from '../internal/collapsible-list/collapsible-list.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport { XButton } from '../internal/x-button/x-button.js';\nimport { Spinner } from '../spinner/spinner.js';\nimport type {\n ApiProps,\n AsyncItemLoadingProps,\n CollectionItem,\n CollectionProps,\n CommonProps,\n FieldWithPlaceholderProps,\n Key,\n StringLikeChildren,\n} from '../types.js';\nimport { textStyle } from '../typography/utils.js';\n\nconst VIRTUAL_LAYOUT_OPTIONS: RACListLayoutOptions = {\n estimatedRowHeight: 40,\n estimatedHeadingHeight: 32,\n loaderHeight: 40,\n padding: 0,\n gap: 0,\n};\n\n/** Represents the state of the `ComboBox` component for validation purposes. */\nexport interface ComboBoxValidationValue {\n /** The selected key in the ComboBox. */\n selectedKey: Key | null;\n /** The value of the ComboBox input. */\n inputValue: string;\n}\n\nexport interface ComboBoxProps<T extends CollectionItem = CollectionItem>\n extends\n CommonProps,\n FieldWithPlaceholderProps<ComboBoxValidationValue>,\n CollectionProps<T>,\n AsyncItemLoadingProps,\n ApiProps<ComboBoxApi>,\n Pick<\n RACComboBoxProps<T>,\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onInputChange'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n > {\n /** The currently selected key in the collection (controlled). */\n selectedKey?: Key | null;\n /** The initial selected key in the collection (uncontrolled). */\n defaultSelectedKey?: Key;\n /** Handler that is called when the selection changes. */\n onSelectionChange?: (key: Key | null) => void;\n /**\n * Whether the list of options should be virtualized. Use this as a performance optimization for large lists.\n * @default false\n */\n isVirtualized?: boolean;\n /** Handler that is called when the list of items is scrolled. */\n onScroll?: UIEventHandler<HTMLDivElement>;\n UNSTABLE_isClearable?: boolean;\n}\n\n/** The imperative API exposed by the `ComboBox` component. */\nexport interface ComboBoxApi {\n /** Focuses the input field and opens the list of items. */\n focus: () => void;\n /** Selects the contents of the input field. */\n select: () => void;\n}\n\nfunction ComboBox<T extends CollectionItem>(\n {\n label,\n description,\n error,\n items,\n children,\n placeholder,\n UNSAFE_className,\n UNSAFE_style,\n isReadOnly,\n onScroll,\n isVirtualized = false,\n UNSTABLE_isLoading: isLoading,\n UNSTABLE_onLoadMore: onLoadMore,\n UNSTABLE_isClearable: isClearable = false,\n apiRef,\n selectedKey,\n defaultSelectedKey,\n onSelectionChange,\n validate,\n ...props\n }: ComboBoxProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('ComboBox requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`ComboBox` requires `children` to be a function when using `items` prop');\n }\n\n useImperativeHandle(\n apiRef,\n () => ({\n focus: () => inputRef.current?.focus(),\n select: () => inputRef.current?.select(),\n }),\n [],\n );\n\n const isFieldClearable = isClearable && !props.isDisabled && !isReadOnly;\n\n const listBox = (\n <ComboBoxList<T> items={items} isLoading={isLoading} onLoadMore={onLoadMore} onScroll={onScroll}>\n {children}\n </ComboBoxList>\n );\n\n return (\n <RACComboBox\n {...props}\n ref={ref}\n className={clsx('cim-combo-box', UNSAFE_className)}\n style={UNSAFE_style}\n selectionMode=\"single\"\n value={selectedKey}\n defaultValue={defaultSelectedKey}\n onChange={onSelectionChange}\n menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n validate={\n validate\n ? ({ inputValue, value }) => {\n return validate({ inputValue, selectedKey: value });\n }\n : undefined\n }\n >\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-combo-box-input-group\">\n <ComboBoxInput\n inputRef={inputRef}\n isReadOnly={isReadOnly}\n placeholder={placeholder}\n isClearable={isFieldClearable}\n />\n {isFieldClearable && <ComboBoxClearButton />}\n <RACButton className=\"cim-combo-box-button\">\n <IconChevronDown />\n </RACButton>\n </RACGroup>\n <FormFieldError>{error}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n <CollapsibleList\n offset={5} // 1px border + 4px actual offset\n maxHeight={315}\n >\n {isVirtualized ? (\n <RACVirtualizer layout={RACListLayout} layoutOptions={VIRTUAL_LAYOUT_OPTIONS}>\n {listBox}\n </RACVirtualizer>\n ) : (\n listBox\n )}\n </CollapsibleList>\n </RACComboBox>\n );\n}\n\n/**\n * Allows users to filter a collapsible list and select one item from it.\n *\n * See [combo box usage guidelines](https://ui.cimpress.io/components/combo-box)\n */\nconst _ComboBox = withStyleProps(forwardRef(ComboBox), 'ComboBox');\n\nexport { _ComboBox as ComboBox };\n\nfunction ComboBoxClearButton() {\n const comboBoxState = useContext(RACComboBoxStateContext);\n const inputValue = comboBoxState?.inputValue;\n\n if (!comboBoxState || inputValue === '') {\n return null;\n }\n\n return (\n <XButton\n onPress={() => {\n comboBoxState?.setValue(null);\n }}\n iconType=\"circled\"\n // TODO: i18n once stabilized\n aria-label=\"Clear selection\"\n // Prevent this button from acting as a trigger for opening/closing the ComboBox\n slot={null}\n excludeFromTabOrder\n />\n );\n}\n\nfunction ComboBoxInput({\n inputRef,\n isReadOnly,\n placeholder,\n isClearable,\n}: {\n inputRef: MutableRefObject<HTMLInputElement | null>;\n isReadOnly: boolean | undefined;\n placeholder: string | undefined;\n isClearable: boolean;\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n\n return (\n <RACInput\n ref={inputRef}\n className={clsx('cim-combo-box-input', textStyle({ variant: 'body' }))}\n // Ensure the popover opens when the input is clicked.\n // By default, React Aria only opens the popover when the input is focused.\n onClick={() => !isReadOnly && comboBoxState!.open()}\n placeholder={placeholder}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && !comboBoxState?.isOpen && isClearable) {\n comboBoxState?.setValue(null);\n }\n }}\n />\n );\n}\n\nfunction ComboBoxList<T extends CollectionItem = CollectionItem>({\n items,\n children,\n isLoading,\n onLoadMore,\n onScroll,\n}: Pick<ComboBoxProps<T>, 'items' | 'children' | 'onScroll'> & {\n isLoading: ComboBoxProps['UNSTABLE_isLoading'];\n onLoadMore: ComboBoxProps['UNSTABLE_onLoadMore'];\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n const collectionMessages = useLocalizedMessages('UNSTABLE_collection');\n\n usePreventScroll({ isDisabled: !comboBoxState?.isOpen });\n\n return (\n <RACListBox\n className=\"cim-combo-box-listbox\"\n onScroll={onScroll}\n renderEmptyState={() =>\n isLoading ? <Spinner aria-label={collectionMessages.format('loading')} size=\"small\" marginY={8} /> : null\n }\n >\n <RACCollection items={items}>{children}</RACCollection>\n <RACListBoxLoadMoreItem onLoadMore={onLoadMore} isLoading={isLoading}>\n <Spinner aria-label={collectionMessages.format('loadingMore')} size=\"small\" marginY={8} />\n </RACListBoxLoadMoreItem>\n </RACListBox>\n );\n}\n\nexport interface ComboBoxItemProps<T extends CollectionItem> extends Pick<\n RACListBoxItemProps<T>,\n 'isDisabled' | 'onHoverStart' | 'onHoverEnd'\n> {\n /** The ID of the item. Has to be unique across all sections and items. */\n id?: Key;\n /** The content to display as the label. */\n children: StringLikeChildren;\n}\n\n/** Renders a single list item within `ComboBox`. */\nexport function ComboBoxItem<T extends CollectionItem>({ children, ...props }: ComboBoxItemProps<T>) {\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <RACListBoxItem {...props} className=\"cim-combo-box-item\" textValue={textValue}>\n {({ isDisabled }) => (\n <>\n <IconCheckBold />\n\n <RACText slot=\"label\" className={textStyle({ variant: 'body', tone: isDisabled ? 'muted' : 'base' })}>\n {children}\n </RACText>\n </>\n )}\n </RACListBoxItem>\n );\n}\n\nComboBoxItem.displayName = 'ComboBoxItem';\n\nexport interface ComboBoxSectionProps<T extends CollectionItem> extends CollectionProps<T> {\n /** The ID of the section. Has to be unique across all sections and items. */\n id?: Key;\n /** The content to display as the section title. */\n title: string;\n}\n\n/** Groups list items within `ComboBox` into a section. */\nexport function ComboBoxSection<T extends CollectionItem>({\n title,\n children,\n items,\n ...props\n}: ComboBoxSectionProps<T>) {\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`ComboBoxSection` requires `children` to be a function when using `items` prop');\n }\n\n return (\n <RACListBoxSection {...props} className=\"cim-combo-box-section\">\n <RACHeader\n className={clsx('cim-combo-box-section-header', textStyle({ variant: 'small-semibold', tone: 'subtle' }))}\n >\n {title}\n </RACHeader>\n <RACCollection items={items}>{children}</RACCollection>\n </RACListBoxSection>\n );\n}\n\nComboBoxSection.displayName = 'ComboBoxSection';\n"]}
1
+ {"version":3,"file":"combo-box.js","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAoWb,oCAiBC;AAYD,0CAoBC;;AAnZD,gDAAwB;AACxB,iCAOe;AACf,2CAA8C;AAC9C,iEAkB+B;AAC/B,yDAAkD;AAClD,kDAA2D;AAC3D,mDAAsE;AACtE,mEAA4D;AAC5D,qFAA6E;AAC7E,mEAA2D;AAC3D,0FAAmF;AACnF,wEAA4G;AAC5G,kEAA2D;AAC3D,sDAAgD;AAWhD,qDAAmD;AAEnD,MAAM,sBAAsB,GAAyB;IACnD,kBAAkB,EAAE,EAAE;IACtB,sBAAsB,EAAE,EAAE;IAC1B,YAAY,EAAE,EAAE;IAChB,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,CAAC;CACP,CAAC;AA4EF,SAAS,QAAQ,CACf,EACE,KAAK,EACL,WAAW,EACX,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,aAAa,GAAG,KAAK,EACrB,WAAW,GAAG,KAAK,EACnB,kBAAkB,EAAE,SAAS,EAC7B,mBAAmB,EAAE,UAAU,EAC/B,MAAM,EACN,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,EACR,GAAG,KAAK,EACS,EACnB,GAAiC;IAEjC,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAmB,IAAI,CAAC,CAAC;IAEhD,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAE7E,IAAA,gDAAoB,EAAC,GAAG,EAAE;QACxB,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,IAAI,CAAC,cAAc,EAAE,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,iFAAiF,CAAC,CAAC;QAClG,CA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SAAS,YAC3E,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CACnB,6DACE,uBAAC,wBAAa,KAAG,EAEjB,uBAAC,4BAAO,IAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAE,IAAA,oBAAS,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,YACjG,QAAQ,GACD,IACT,CACJ,GACc,CAClB,CAAC;AACJ,CAAC;AAED,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC;AAS1C,0DAA0D;AAC1D,SAAgB,eAAe,CAA2B,EACxD,KAAK,EACL,QAAQ,EACR,KAAK,EACL,GAAG,KAAK,EACgB;IACxB,IAAI,CAAC,IAAA,+BAAY,GAAE,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACvE,OAAO,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,CACL,wBAAC,sCAAiB,OAAK,KAAK,EAAE,SAAS,EAAC,uBAAuB,aAC7D,uBAAC,8BAAS,IACR,SAAS,EAAE,IAAA,cAAI,EAAC,8BAA8B,EAAE,IAAA,oBAAS,EAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,YAExG,KAAK,GACI,EACZ,uBAAC,kCAAa,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAiB,IACrC,CACrB,CAAC;AACJ,CAAC;AAED,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport {\n type ForwardedRef,\n type MutableRefObject,\n type UIEventHandler,\n useContext,\n useImperativeHandle,\n useRef,\n} from 'react';\nimport { usePreventScroll } from 'react-aria';\nimport {\n Button as RACButton,\n Collection as RACCollection,\n ComboBox as RACComboBox,\n ComboBoxStateContext as RACComboBoxStateContext,\n Group as RACGroup,\n Header as RACHeader,\n Input as RACInput,\n ListBox as RACListBox,\n ListBoxLoadMoreItem as RACListBoxLoadMoreItem,\n ListBoxItem as RACListBoxItem,\n ListBoxSection as RACListBoxSection,\n ListLayout as RACListLayout,\n type ListLayoutOptions as RACListLayoutOptions,\n Text as RACText,\n type ComboBoxProps as RACComboBoxProps,\n type ListBoxItemProps as RACListBoxItemProps,\n Virtualizer as RACVirtualizer,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/index.js';\nimport { IconCheckBold, IconChevronDown } from '../../icons/index.js';\nimport { isProduction } from '../../utils/is-production.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { CollapsibleList } from '../internal/collapsible-list/collapsible-list.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport { XButton } from '../internal/x-button/x-button.js';\nimport { Spinner } from '../spinner/spinner.js';\nimport type {\n ApiProps,\n AsyncItemLoadingProps,\n CollectionItem,\n CollectionProps,\n CommonProps,\n FieldWithPlaceholderProps,\n Key,\n StringLikeChildren,\n} from '../types.js';\nimport { textStyle } from '../typography/utils.js';\n\nconst VIRTUAL_LAYOUT_OPTIONS: RACListLayoutOptions = {\n estimatedRowHeight: 40,\n estimatedHeadingHeight: 32,\n loaderHeight: 40,\n padding: 0,\n gap: 0,\n};\n\n/** Represents the state of the `ComboBox` component for validation purposes. */\nexport interface ComboBoxValidationValue {\n /** The selected key in the combo box. */\n value: Key | null;\n /** The value of the combo box input. */\n inputValue: string;\n /**\n * The selected key in the combo box.\n * @deprecated Use `value` instead.\n */\n selectedKey: Key | null;\n}\n\nexport interface ComboBoxProps<T extends CollectionItem = CollectionItem>\n extends\n CommonProps,\n FieldWithPlaceholderProps<ComboBoxValidationValue>,\n CollectionProps<T>,\n AsyncItemLoadingProps,\n ApiProps<ComboBoxApi>,\n Pick<\n RACComboBoxProps<T>,\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onInputChange'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n > {\n /** The current value (controlled). */\n value?: Key | null;\n /** The initial value (uncontrolled). */\n defaultValue?: Key;\n /** Handler that is called when the value changes. */\n onChange?: (key: Key | null) => void;\n /**\n * The currently selected key in the collection (controlled).\n * @deprecated Use `value` instead.\n */\n selectedKey?: Key | null;\n /**\n * The initial selected key in the collection (uncontrolled).\n * @deprecated Use `defaultValue` instead.\n */\n defaultSelectedKey?: Key;\n /**\n * Handler that is called when the selection changes.\n * @deprecated Use `onChange` instead.\n */\n onSelectionChange?: (key: Key | null) => void;\n /** Whether to display a clear button to clear the selection. */\n isClearable?: boolean;\n /**\n * Whether the list of options should be virtualized. Use this as a performance optimization for large lists.\n * @default false\n */\n isVirtualized?: boolean;\n /** Handler that is called when the list of items is scrolled. */\n onScroll?: UIEventHandler<HTMLDivElement>;\n}\n\n/** The imperative API exposed by the `ComboBox` component. */\nexport interface ComboBoxApi {\n /** Focuses the input field and opens the list of items. */\n focus: () => void;\n /** Selects the contents of the input field. */\n select: () => void;\n}\n\nfunction ComboBox<T extends CollectionItem>(\n {\n label,\n description,\n error,\n items,\n children,\n placeholder,\n UNSAFE_className,\n UNSAFE_style,\n isReadOnly,\n onScroll,\n isVirtualized = false,\n isClearable = false,\n UNSTABLE_isLoading: isLoading,\n UNSTABLE_onLoadMore: onLoadMore,\n apiRef,\n value,\n defaultValue,\n onChange,\n selectedKey,\n defaultSelectedKey,\n onSelectionChange,\n validate,\n ...props\n }: ComboBoxProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('ComboBox requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`ComboBox` requires `children` to be a function when using `items` prop');\n }\n\n useImperativeHandle(\n apiRef,\n () => ({\n focus: () => inputRef.current?.focus(),\n select: () => inputRef.current?.select(),\n }),\n [],\n );\n\n const isFieldClearable = isClearable && !props.isDisabled && !isReadOnly;\n\n const listBox = (\n <ComboBoxList<T> items={items} isLoading={isLoading} onLoadMore={onLoadMore} onScroll={onScroll}>\n {children}\n </ComboBoxList>\n );\n\n return (\n <RACComboBox\n {...props}\n ref={ref}\n className={clsx('cim-combo-box', UNSAFE_className)}\n style={UNSAFE_style}\n selectionMode=\"single\"\n value={value}\n defaultValue={defaultValue}\n onChange={onChange}\n selectedKey={selectedKey}\n defaultSelectedKey={defaultSelectedKey}\n onSelectionChange={onSelectionChange}\n menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n validate={\n validate\n ? ({ inputValue, value }) => {\n return validate({ inputValue, value, selectedKey: value });\n }\n : undefined\n }\n >\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-combo-box-input-group\">\n <ComboBoxInput\n inputRef={inputRef}\n isReadOnly={isReadOnly}\n placeholder={placeholder}\n isClearable={isFieldClearable}\n />\n {isFieldClearable && <ComboBoxClearButton onClear={() => inputRef.current?.focus()} />}\n <RACButton className=\"cim-combo-box-button\">\n <IconChevronDown />\n </RACButton>\n </RACGroup>\n <FormFieldError>{error}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n <CollapsibleList\n offset={5} // 1px border + 4px actual offset\n maxHeight={315}\n >\n {isVirtualized ? (\n <RACVirtualizer layout={RACListLayout} layoutOptions={VIRTUAL_LAYOUT_OPTIONS}>\n {listBox}\n </RACVirtualizer>\n ) : (\n listBox\n )}\n </CollapsibleList>\n </RACComboBox>\n );\n}\n\n/**\n * Allows users to filter a collapsible list and select one item from it.\n *\n * See [combo box usage guidelines](https://ui.cimpress.io/components/combo-box)\n */\nconst _ComboBox = withStyleProps(forwardRef(ComboBox), 'ComboBox');\n\nexport { _ComboBox as ComboBox };\n\nfunction ComboBoxClearButton({ onClear }: { onClear?: () => void }) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n const selectMessages = useLocalizedMessages('select');\n const inputValue = comboBoxState?.inputValue;\n\n if (!comboBoxState || inputValue === '') {\n return null;\n }\n\n return (\n <XButton\n onPress={() => {\n comboBoxState.setValue(null);\n onClear?.();\n }}\n iconType=\"circled\"\n aria-label={selectMessages.format('clearSelection')}\n // Prevent this button from acting as a trigger for opening/closing the ComboBox\n slot={null}\n excludeFromTabOrder\n />\n );\n}\n\nfunction ComboBoxInput({\n inputRef,\n isReadOnly,\n placeholder,\n isClearable,\n}: {\n inputRef: MutableRefObject<HTMLInputElement | null>;\n isReadOnly: boolean | undefined;\n placeholder: string | undefined;\n isClearable: boolean;\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n\n return (\n <RACInput\n ref={inputRef}\n className={clsx('cim-combo-box-input', textStyle({ variant: 'body' }))}\n // Ensure the popover opens when the input is clicked.\n // By default, React Aria only opens the popover when the input is focused.\n onClick={() => !isReadOnly && comboBoxState!.open()}\n placeholder={placeholder}\n onKeyDown={(e) => {\n if (e.key === 'Escape' && !comboBoxState?.isOpen && isClearable) {\n comboBoxState?.setValue(null);\n }\n }}\n />\n );\n}\n\nfunction ComboBoxList<T extends CollectionItem = CollectionItem>({\n items,\n children,\n isLoading,\n onLoadMore,\n onScroll,\n}: Pick<ComboBoxProps<T>, 'items' | 'children' | 'onScroll'> & {\n isLoading: ComboBoxProps['UNSTABLE_isLoading'];\n onLoadMore: ComboBoxProps['UNSTABLE_onLoadMore'];\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n const collectionMessages = useLocalizedMessages('UNSTABLE_collection');\n\n usePreventScroll({ isDisabled: !comboBoxState?.isOpen });\n\n return (\n <RACListBox\n className=\"cim-combo-box-listbox\"\n onScroll={onScroll}\n renderEmptyState={() =>\n isLoading ? <Spinner aria-label={collectionMessages.format('loading')} size=\"small\" marginY={8} /> : null\n }\n >\n <RACCollection items={items}>{children}</RACCollection>\n <RACListBoxLoadMoreItem onLoadMore={onLoadMore} isLoading={isLoading}>\n <Spinner aria-label={collectionMessages.format('loadingMore')} size=\"small\" marginY={8} />\n </RACListBoxLoadMoreItem>\n </RACListBox>\n );\n}\n\nexport interface ComboBoxItemProps<T extends CollectionItem> extends Pick<\n RACListBoxItemProps<T>,\n 'isDisabled' | 'onHoverStart' | 'onHoverEnd'\n> {\n /** The ID of the item. Has to be unique across all sections and items. */\n id?: Key;\n /** The content to display as the label. */\n children: StringLikeChildren;\n}\n\n/** Renders a single list item within `ComboBox`. */\nexport function ComboBoxItem<T extends CollectionItem>({ children, ...props }: ComboBoxItemProps<T>) {\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <RACListBoxItem {...props} className=\"cim-combo-box-item\" textValue={textValue}>\n {({ isDisabled }) => (\n <>\n <IconCheckBold />\n\n <RACText slot=\"label\" className={textStyle({ variant: 'body', tone: isDisabled ? 'muted' : 'base' })}>\n {children}\n </RACText>\n </>\n )}\n </RACListBoxItem>\n );\n}\n\nComboBoxItem.displayName = 'ComboBoxItem';\n\nexport interface ComboBoxSectionProps<T extends CollectionItem> extends CollectionProps<T> {\n /** The ID of the section. Has to be unique across all sections and items. */\n id?: Key;\n /** The content to display as the section title. */\n title: string;\n}\n\n/** Groups list items within `ComboBox` into a section. */\nexport function ComboBoxSection<T extends CollectionItem>({\n title,\n children,\n items,\n ...props\n}: ComboBoxSectionProps<T>) {\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`ComboBoxSection` requires `children` to be a function when using `items` prop');\n }\n\n return (\n <RACListBoxSection {...props} className=\"cim-combo-box-section\">\n <RACHeader\n className={clsx('cim-combo-box-section-header', textStyle({ variant: 'small-semibold', tone: 'subtle' }))}\n >\n {title}\n </RACHeader>\n <RACCollection items={items}>{children}</RACCollection>\n </RACListBoxSection>\n );\n}\n\nComboBoxSection.displayName = 'ComboBoxSection';\n"]}
@@ -1,14 +1,36 @@
1
- import { type UIEventHandler } from 'react';
1
+ import { type ReactNode, type UIEventHandler } from 'react';
2
2
  import { type ListBoxItemProps as RACListBoxItemProps, type SelectProps as RACSelectProps } from 'react-aria-components';
3
3
  import type { ApiProps, AsyncItemLoadingProps, CollectionItem, CollectionProps, CommonProps, FieldProps, Key, StringLikeChildren } from '../types.js';
4
- export type UNSTABLE_SelectSelectionMode = 'single' | 'multiple';
5
- export interface SelectProps<T extends CollectionItem = CollectionItem, M extends UNSTABLE_SelectSelectionMode = 'single'> extends CommonProps, FieldProps<M extends 'single' ? Key : Key[]>, CollectionProps<T>, AsyncItemLoadingProps, ApiProps<SelectApi>, Pick<RACSelectProps<T, M>, 'isDisabled' | 'isRequired' | 'isInvalid' | 'autoComplete' | 'autoFocus' | 'placeholder' | 'onFocus' | 'onBlur' | 'onOpenChange'> {
6
- /** The currently selected key in the collection (controlled). */
4
+ export type SelectSelectionMode = 'single' | 'multiple';
5
+ export interface SelectProps<T extends CollectionItem = CollectionItem, M extends SelectSelectionMode = 'single'> extends CommonProps, FieldProps<M extends 'single' ? Key : Key[]>, CollectionProps<T>, AsyncItemLoadingProps, ApiProps<SelectApi>, Pick<RACSelectProps<T, M>, 'isDisabled' | 'isRequired' | 'isInvalid' | 'autoComplete' | 'autoFocus' | 'placeholder' | 'onFocus' | 'onBlur' | 'onOpenChange'> {
6
+ /**
7
+ * The selection mode of the select.
8
+ * @default 'single'
9
+ */
10
+ selectionMode?: M;
11
+ /** The current value (controlled). */
12
+ value?: M extends 'single' ? Key | null : Key[];
13
+ /** The initial value (uncontrolled). */
14
+ defaultValue?: M extends 'single' ? Key : Key[];
15
+ /** Handler that is called when the value changes. */
16
+ onChange?: (key: M extends 'single' ? Key | null : Key[]) => void;
17
+ /**
18
+ * The currently selected key in the collection (controlled).
19
+ * @deprecated Use `value` instead. Not compatible with `selectionMode="multiple"`.
20
+ */
7
21
  selectedKey?: Key | null;
8
- /** The initial selected key in the collection (uncontrolled). */
22
+ /**
23
+ * The initial selected key in the collection (uncontrolled).
24
+ * @deprecated Use `defaultValue` instead. Not compatible with `selectionMode="multiple"`.
25
+ */
9
26
  defaultSelectedKey?: Key;
10
- /** Handler that is called when the selection changes. */
27
+ /**
28
+ * Handler that is called when the selection changes.
29
+ * @deprecated Use `onChange` instead. Not compatible with `selectionMode="multiple"`.
30
+ */
11
31
  onSelectionChange?: (key: Key | null) => void;
32
+ /** Whether to display a clear button to clear the selection. */
33
+ isClearable?: boolean;
12
34
  /**
13
35
  * Whether the list of options should be virtualized. Use this as a performance optimization for large lists.
14
36
  * @default false
@@ -16,39 +38,22 @@ export interface SelectProps<T extends CollectionItem = CollectionItem, M extend
16
38
  isVirtualized?: boolean;
17
39
  /** Handler that is called when the list of items is scrolled. */
18
40
  onScroll?: UIEventHandler<HTMLDivElement>;
19
- /**
20
- * The selection mode of the select.
21
- * @default 'single'
22
- */
23
- UNSTABLE_selectionMode?: M;
24
- /** The value of the select (controlled). */
25
- UNSTABLE_value?: M extends 'single' ? Key | null : Key[];
26
- /** The initial value of the select (uncontrolled). */
27
- UNSTABLE_defaultValue?: M extends 'single' ? Key : Key[];
28
- /** Handler that is called when the value changes. */
29
- UNSTABLE_onChange?: (key: M extends 'single' ? Key | null : Key[]) => void;
30
- /**
31
- * How the selected value is displayed.
32
- * @default 'text'
33
- */
34
- UNSTABLE_valueDisplay?: 'text' | 'tags' | 'count';
35
41
  /**
36
42
  * Whether the list of options should be filterable.
37
43
  * @default false
38
44
  */
39
- UNSTABLE_isFilterable?: boolean;
45
+ isFilterable?: boolean;
40
46
  /** The value of the filter input (controlled). */
41
- UNSTABLE_filterValue?: string;
47
+ filterValue?: string;
42
48
  /** The initial value of the filter input (uncontrolled). */
43
- UNSTABLE_defaultFilterValue?: string;
49
+ defaultFilterValue?: string;
44
50
  /** Handler that is called when the filter value changes. */
45
- UNSTABLE_onFilterChange?: (value: string) => void;
51
+ onFilterChange?: (value: string) => void;
46
52
  /** A custom filter function to use instead of the default filter. */
47
- UNSTABLE_filter?: ((textValue: string, inputValue: string, node: {
53
+ UNSTABLE_filter?: ((textValue: string, inputValue: string, item: {
48
54
  key: Key;
49
55
  value: T | null;
50
56
  }) => boolean) | null;
51
- UNSTABLE_isClearable?: boolean;
52
57
  }
53
58
  /** The imperative API exposed by the `Select` component. */
54
59
  export interface SelectApi {
@@ -56,20 +61,26 @@ export interface SelectApi {
56
61
  focus: () => void;
57
62
  }
58
63
  /**
59
- * Allows users to select one item from a collapsible list.
64
+ * Allows users to select one or more items from a collapsible list.
60
65
  *
61
66
  * See [select usage guidelines](https://ui.cimpress.io/components/select/).
62
67
  */
63
- declare const _Select: <T extends CollectionItem, M extends UNSTABLE_SelectSelectionMode = "single">(props: SelectProps<T, M> & import("react").RefAttributes<HTMLDivElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
68
+ declare const _Select: <T extends CollectionItem, M extends SelectSelectionMode = "single">(props: SelectProps<T, M> & import("react").RefAttributes<HTMLDivElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
64
69
  export { _Select as Select };
65
70
  export interface SelectItemProps extends Pick<RACListBoxItemProps, 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {
66
71
  /** The ID of the item. Has to be unique across all sections and items. */
67
72
  id?: Key;
68
73
  /** The content to display as the label. */
69
74
  children: StringLikeChildren;
75
+ /** Additional description for the item. */
76
+ description?: string;
77
+ /** A non-interactive piece of content displayed at the start of the item. */
78
+ icon?: ReactNode;
79
+ /** A non-interactive piece of content displayed at the end of the item. */
80
+ UNSTABLE_meta?: ReactNode;
70
81
  }
71
82
  /** Renders a single list item within `Select`. */
72
- export declare function SelectItem({ children, ...props }: SelectItemProps): import("react/jsx-runtime").JSX.Element;
83
+ export declare function SelectItem({ children, description, icon, UNSTABLE_meta: meta, ...props }: SelectItemProps): import("react/jsx-runtime").JSX.Element;
73
84
  export declare namespace SelectItem {
74
85
  var displayName: string;
75
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../src/components/select/select.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,cAAc,EAKpB,MAAM,OAAO,CAAC;AAEf,OAAO,EAQL,KAAK,gBAAgB,IAAI,mBAAmB,EAO5C,KAAK,WAAW,IAAI,cAAc,EAMnC,MAAM,uBAAuB,CAAC;AAgB/B,OAAO,KAAK,EACV,QAAQ,EACR,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,WAAW,EACX,UAAU,EACV,GAAG,EACH,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAKrB,MAAM,MAAM,4BAA4B,GAAG,QAAQ,GAAG,UAAU,CAAC;AAUjE,MAAM,WAAW,WAAW,CAC1B,CAAC,SAAS,cAAc,GAAG,cAAc,EACzC,CAAC,SAAS,4BAA4B,GAAG,QAAQ,CAEjD,SACE,WAAW,EACX,UAAU,CAAC,CAAC,SAAS,QAAQ,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC,EAC5C,eAAe,CAAC,CAAC,CAAC,EAClB,qBAAqB,EACrB,QAAQ,CAAC,SAAS,CAAC,EACnB,IAAI,CACF,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,EAClB,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,cAAc,GACd,WAAW,GACX,aAAa,GACb,SAAS,GACT,QAAQ,GACR,cAAc,CACjB;IACH,iEAAiE;IACjE,WAAW,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IACzB,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,GAAG,CAAC;IACzB,yDAAyD;IACzD,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAA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AE,eAAe,2CAgCzG;yBAhCe,UAAU;;;AAoC1B,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IACtF,6EAA6E;IAC7E,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,CAAC,SAAS,cAAc,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,CAAC,CAAC,CAAC,2CAelH;yBAfe,aAAa"}
@@ -8,7 +8,6 @@ exports.Select = void 0;
8
8
  exports.SelectItem = SelectItem;
9
9
  exports.SelectSection = SelectSection;
10
10
  const jsx_runtime_1 = require("react/jsx-runtime");
11
- const utils_1 = require("@react-aria/utils");
12
11
  const clsx_1 = __importDefault(require("clsx"));
13
12
  const react_1 = require("react");
14
13
  const react_aria_1 = require("react-aria");
@@ -30,7 +29,6 @@ const tag_js_1 = require("../tag/tag.js");
30
29
  const search_field_js_1 = require("../text-inputs/search-field.js");
31
30
  const text_js_1 = require("../typography/text.js");
32
31
  const utils_js_1 = require("../typography/utils.js");
33
- const visually_hidden_js_1 = require("../visually-hidden/visually-hidden.js");
34
32
  const VIRTUAL_LAYOUT_OPTIONS = {
35
33
  estimatedRowHeight: 40,
36
34
  estimatedHeadingHeight: 32,
@@ -38,8 +36,9 @@ const VIRTUAL_LAYOUT_OPTIONS = {
38
36
  padding: 0,
39
37
  gap: 0,
40
38
  };
41
- function Select({ children, items, label, description, error, UNSAFE_className, UNSAFE_style, onScroll, isVirtualized = false, apiRef, UNSTABLE_isLoading: isLoading, UNSTABLE_onLoadMore: onLoadMore, selectedKey, defaultSelectedKey, onSelectionChange, UNSTABLE_selectionMode, UNSTABLE_value, UNSTABLE_defaultValue, UNSTABLE_onChange, UNSTABLE_valueDisplay: valueDisplay = 'text', UNSTABLE_isFilterable: isFilterable = false, UNSTABLE_filterValue: filterValue, UNSTABLE_defaultFilterValue: defaultFilterValue, UNSTABLE_onFilterChange: onFilterChange, UNSTABLE_filter: filter, UNSTABLE_isClearable: isClearable = false, ...props }, ref) {
39
+ function Select({ children, items, label, description, error, UNSAFE_className, UNSAFE_style, onScroll, isVirtualized = false, apiRef, UNSTABLE_isLoading: isLoading, UNSTABLE_onLoadMore: onLoadMore, selectedKey, defaultSelectedKey, onSelectionChange, selectionMode = 'single', value, defaultValue, onChange, isClearable = false, isFilterable = false, filterValue, defaultFilterValue, onFilterChange, UNSTABLE_filter: filter, id, isDisabled, ...props }, ref) {
42
40
  const triggerRef = (0, react_1.useRef)(null);
41
+ const selectId = (0, react_aria_1.useId)(id);
43
42
  const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;
44
43
  (0, use_production_warning_js_1.useProductionWarning)(() => {
45
44
  if (!label && !ariaLabel && !ariaLabelledBy) {
@@ -55,7 +54,7 @@ function Select({ children, items, label, description, error, UNSAFE_className,
55
54
  const listBox = ((0, jsx_runtime_1.jsx)(SelectListBox, { items: items, isLoading: isLoading, onLoadMore: onLoadMore, onScroll: onScroll, children: children }));
56
55
  const listBoxWithVirtualizer = isVirtualized ? ((0, jsx_runtime_1.jsx)(react_aria_components_1.Virtualizer, { layout: react_aria_components_1.ListLayout, layoutOptions: VIRTUAL_LAYOUT_OPTIONS, children: listBox })) : (listBox);
57
56
  const listBoxWithFilter = isFilterable ? ((0, jsx_runtime_1.jsx)(SelectFilter, { filterValue: filterValue, defaultFilterValue: defaultFilterValue, onFilterChange: onFilterChange, filter: filter, children: listBoxWithVirtualizer })) : (listBoxWithVirtualizer);
58
- return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.Select, { ...props, ref: ref, className: (0, clsx_1.default)('cim-select', UNSAFE_className), style: UNSAFE_style, selectedKey: selectedKey, defaultSelectedKey: defaultSelectedKey, onSelectionChange: onSelectionChange, value: UNSTABLE_value, defaultValue: UNSTABLE_defaultValue, onChange: UNSTABLE_onChange, selectionMode: UNSTABLE_selectionMode, allowsEmptyCollection: isLoading, children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: props.isRequired, isDisabled: props.isDisabled, children: label }), (0, jsx_runtime_1.jsx)(SelectButton, { ref: triggerRef, valueDisplay: valueDisplay, isClearable: isClearable }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: error }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description }), (0, jsx_runtime_1.jsx)(SelectPopover, { children: listBoxWithFilter }), UNSTABLE_selectionMode === 'multiple' && valueDisplay === 'tags' && (0, jsx_runtime_1.jsx)(SelectTags, {})] }));
57
+ return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.Select, { ...props, ref: ref, id: selectId, className: (0, clsx_1.default)('cim-select', UNSAFE_className), style: UNSAFE_style, selectedKey: selectedKey, defaultSelectedKey: defaultSelectedKey, onSelectionChange: onSelectionChange, value: value, defaultValue: defaultValue, onChange: onChange, selectionMode: selectionMode, allowsEmptyCollection: isLoading, isDisabled: isDisabled, children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: props.isRequired, isDisabled: isDisabled, children: label }), (0, jsx_runtime_1.jsx)(SelectButton, { ref: triggerRef, selectId: selectId, isDisabled: isDisabled, isClearable: isClearable, selectionMode: selectionMode }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: error }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description }), (0, jsx_runtime_1.jsx)(SelectPopover, { children: listBoxWithFilter })] }));
59
58
  }
60
59
  function SelectPopover({ children }) {
61
60
  const popoverRef = (0, react_1.useRef)(null);
@@ -83,14 +82,22 @@ function SelectPopover({ children }) {
83
82
  // Set to non-modal so that interactions like clicking the clear button can be performed without first having to close the popover
84
83
  isNonModal: true, children: children }));
85
84
  }
86
- const SelectButton = (0, forward_ref_js_1.forwardRef)(({ valueDisplay, isClearable }, ref) => {
87
- const triggerRef = (0, react_1.useRef)(null);
88
- const collectionMessages = (0, index_js_1.useLocalizedMessages)('UNSTABLE_collection');
89
- return ((0, jsx_runtime_1.jsxs)("div", { className: "cim-select-button", children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.Button, { ref: (0, utils_1.mergeRefs)(ref, triggerRef), className: "cim-select-button-trigger" }), (0, jsx_runtime_1.jsx)(react_aria_components_1.SelectValue, { className: (0, clsx_1.default)('cim-select-button-value', (0, utils_js_1.textStyle)({ variant: 'body', alignment: 'start' })), children: ({ selectedText, defaultChildren, isPlaceholder, state }) => {
90
- if ((valueDisplay === 'tags' && state.selectedItems.length > 0) || valueDisplay === 'count') {
91
- return ((0, jsx_runtime_1.jsx)(text_js_1.Text, { as: "span", variant: "body", tone: "subtle", children: collectionMessages.format('itemsSelected', { selectedItemCount: state.selectedItems.length }) }));
85
+ const SelectButton = (0, forward_ref_js_1.forwardRef)(({ selectId, isDisabled, isClearable, selectionMode }, ref) => {
86
+ const triggerRef = (0, react_aria_1.useObjectRef)(ref);
87
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "cim-select-button", children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.Button, { ref: triggerRef, className: "cim-select-button-trigger" }), (0, jsx_runtime_1.jsx)(react_aria_components_1.SelectValue, { className: (0, clsx_1.default)('cim-select-button-value', (0, utils_js_1.textStyle)({ variant: 'body', alignment: 'start' })), "data-testid": "select-button-value", children: ({ defaultChildren, isPlaceholder, state }) => {
88
+ if (isPlaceholder) {
89
+ return (0, jsx_runtime_1.jsx)("span", { className: "cim-select-button-value-text", children: defaultChildren });
90
+ }
91
+ if (selectionMode === 'multiple') {
92
+ return ((0, jsx_runtime_1.jsx)(tag_group_js_1.TagGroup, { "aria-labelledby": selectId, disabledKeys: isDisabled ? state.selectedItems.map((item) => item.key) : undefined, items: state.selectedItems.filter((item) => item != null).map((item) => ({ id: item.key, item })), onRemove: isDisabled
93
+ ? undefined
94
+ : (keys) => {
95
+ if (Array.isArray(state.value)) {
96
+ state.setValue(state.value.filter((k) => !keys.has(k)));
97
+ }
98
+ }, UNSAFE_className: "cim-select-tags", children: ({ item }) => (0, jsx_runtime_1.jsx)(tag_js_1.Tag, { isDisabled: item.props.isDisabled, children: item.textValue }) }));
92
99
  }
93
- return isPlaceholder ? defaultChildren : selectedText;
100
+ return defaultChildren;
94
101
  } }), isClearable && ((0, jsx_runtime_1.jsx)(SelectClearButton
95
102
  // Move focus to trigger button, because button will disappear after clearing
96
103
  , {
@@ -99,25 +106,24 @@ const SelectButton = (0, forward_ref_js_1.forwardRef)(({ valueDisplay, isClearab
99
106
  });
100
107
  function SelectClearButton({ onClear }) {
101
108
  const selectState = (0, react_1.useContext)(react_aria_components_1.SelectStateContext);
109
+ const selectMessages = (0, index_js_1.useLocalizedMessages)('select');
102
110
  if (!selectState || selectState.selectedItems.length === 0) {
103
111
  return null;
104
112
  }
105
- return ((0, jsx_runtime_1.jsx)(x_button_js_1.XButton
106
- // TODO: i18n once stabilized
107
- , { "aria-label": "Clear selection", iconType: "circled", onPress: () => {
113
+ return ((0, jsx_runtime_1.jsx)(x_button_js_1.XButton, { "aria-label": selectMessages.format('clearSelection'), iconType: "circled", onPress: () => {
108
114
  selectState.setValue(null);
109
115
  onClear?.();
110
116
  }, slot: null, UNSAFE_className: "cim-select-button-clear" }));
111
117
  }
112
118
  function SelectListBox({ children, items, isLoading, onLoadMore, ...props }) {
113
119
  const collectionMessages = (0, index_js_1.useLocalizedMessages)('UNSTABLE_collection');
120
+ const selectMessages = (0, index_js_1.useLocalizedMessages)('select');
114
121
  const selectState = (0, react_1.useContext)(react_aria_components_1.SelectStateContext);
115
122
  const isEmpty = selectState?.collection.size === 0;
116
- return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ListBox, { className: "cim-select-listbox", renderEmptyState: () => !isLoading && (
117
- // TODO: i18n once stabilized
118
- (0, jsx_runtime_1.jsx)(text_js_1.Text, { as: "p", variant: "body", tone: "subtle", marginX: 8, marginY: 8, UNSAFE_className: "cim-select-listbox-empty-state", children: "No results found." })), ...props, children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.Collection, { items: items, children: children }), (0, jsx_runtime_1.jsx)(react_aria_components_1.ListBoxLoadMoreItem, { onLoadMore: onLoadMore, isLoading: isLoading, children: (0, jsx_runtime_1.jsx)(spinner_js_1.Spinner, { "aria-label": collectionMessages.format(isEmpty ? 'loading' : 'loadingMore'), size: "small", marginY: 8 }) })] }));
123
+ return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ListBox, { className: "cim-select-listbox", renderEmptyState: () => !isLoading && ((0, jsx_runtime_1.jsx)(text_js_1.Text, { as: "p", variant: "body", tone: "subtle", marginX: 8, marginY: 8, UNSAFE_className: "cim-select-listbox-empty-state", children: selectMessages.format('noResultsFound') })), ...props, children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.Collection, { items: items, children: children }), (0, jsx_runtime_1.jsx)(react_aria_components_1.ListBoxLoadMoreItem, { onLoadMore: onLoadMore, isLoading: isLoading, children: (0, jsx_runtime_1.jsx)(spinner_js_1.Spinner, { "aria-label": collectionMessages.format(isEmpty ? 'loading' : 'loadingMore'), size: "small", marginY: 8 }) })] }));
119
124
  }
120
125
  function SelectFilter({ children, filterValue, defaultFilterValue, onFilterChange, filter, }) {
126
+ const selectMessages = (0, index_js_1.useLocalizedMessages)('select');
121
127
  const { contains } = (0, react_aria_1.useFilter)({ sensitivity: 'base' });
122
128
  const filterFn = (0, react_1.useMemo)(() => {
123
129
  if (filter === null)
@@ -128,37 +134,19 @@ function SelectFilter({ children, filterValue, defaultFilterValue, onFilterChang
128
134
  return filter(textValue, inputValue, { key: node.key, value: node.value });
129
135
  };
130
136
  }, [filter, contains]);
131
- return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.Autocomplete, { filter: filterFn, inputValue: filterValue, defaultInputValue: defaultFilterValue, onInputChange: onFilterChange, children: [(0, jsx_runtime_1.jsx)(search_field_js_1.SearchField
132
- // TODO: i18n once stabilized
133
- , { "aria-label": "Search", placeholder: "Search", autoFocus: true, marginX: 8, marginTop: 8 }), children] }));
134
- }
135
- function SelectTags() {
136
- const labelContext = (0, react_aria_components_1.useSlottedContext)(react_aria_components_1.LabelContext);
137
- const selectedItemsLabelId = (0, react_aria_1.useId)();
138
- return ((0, jsx_runtime_1.jsx)(react_aria_components_1.SelectValue, { children: ({ state }) => {
139
- if (state.selectedItems.length === 0) {
140
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
141
- }
142
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(tag_group_js_1.TagGroup, { "aria-labelledby": [labelContext?.id, selectedItemsLabelId].filter(Boolean).join(' '), items: state.selectedItems
143
- .filter((item) => item != null)
144
- .map((item) => ({ id: item.key, label: item.textValue })), onRemove: (keys) => {
145
- if (Array.isArray(state.value)) {
146
- state.setValue(state.value.filter((k) => !keys.has(k)));
147
- }
148
- }, marginTop: 8, children: (item) => (0, jsx_runtime_1.jsx)(tag_js_1.Tag, { children: item.label }) }), (0, jsx_runtime_1.jsx)(visually_hidden_js_1.UNSTABLE_VisuallyHidden, { id: selectedItemsLabelId, children: "selected items" })] }));
149
- } }));
137
+ return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.Autocomplete, { filter: filterFn, inputValue: filterValue, defaultInputValue: defaultFilterValue, onInputChange: onFilterChange, children: [(0, jsx_runtime_1.jsx)(search_field_js_1.SearchField, { "aria-label": selectMessages.format('searchLabel'), placeholder: selectMessages.format('searchPlaceholder'), autoFocus: true, UNSAFE_className: "cim-select-search-field" }), children] }));
150
138
  }
151
139
  /**
152
- * Allows users to select one item from a collapsible list.
140
+ * Allows users to select one or more items from a collapsible list.
153
141
  *
154
142
  * See [select usage guidelines](https://ui.cimpress.io/components/select/).
155
143
  */
156
144
  const _Select = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(Select), 'Select');
157
145
  exports.Select = _Select;
158
146
  /** Renders a single list item within `Select`. */
159
- function SelectItem({ children, ...props }) {
147
+ function SelectItem({ children, description, icon, UNSTABLE_meta: meta, ...props }) {
160
148
  const textValue = (0, string_like_children_to_string_js_1.stringLikeChildrenToString)(children);
161
- return ((0, jsx_runtime_1.jsx)(react_aria_components_1.ListBoxItem, { ...props, className: "cim-select-item", textValue: textValue, children: ({ isDisabled, isSelected, selectionMode }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [selectionMode === 'single' && (0, jsx_runtime_1.jsx)(index_js_2.IconCheckBold, {}), selectionMode === 'multiple' && (0, jsx_runtime_1.jsx)(checkbox_indicator_js_1.CheckboxIndicator, { isSelected: isSelected, isDisabled: isDisabled }), (0, jsx_runtime_1.jsx)(react_aria_components_1.Text, { slot: "label", className: (0, utils_js_1.textStyle)({ variant: 'body', tone: isDisabled ? 'muted' : 'base' }), children: children })] })) }));
149
+ return ((0, jsx_runtime_1.jsx)(react_aria_components_1.ListBoxItem, { ...props, className: "cim-select-item", textValue: textValue, children: ({ isDisabled, isSelected, selectionMode }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [selectionMode === 'single' && (0, jsx_runtime_1.jsx)(index_js_2.IconCheckBold, { "data-selection-indicator": true }), selectionMode === 'multiple' && (0, jsx_runtime_1.jsx)(checkbox_indicator_js_1.CheckboxIndicator, { isSelected: isSelected, isDisabled: isDisabled }), icon && (0, jsx_runtime_1.jsx)("div", { className: "cim-select-item-slot", children: icon }), (0, jsx_runtime_1.jsxs)("div", { className: "cim-select-item-text", children: [(0, jsx_runtime_1.jsx)(react_aria_components_1.Text, { slot: "label", className: (0, utils_js_1.textStyle)({ variant: 'body', tone: isDisabled ? 'muted' : 'base' }), children: children }), description && ((0, jsx_runtime_1.jsx)(react_aria_components_1.Text, { slot: "description", className: (0, utils_js_1.textStyle)({ variant: 'small', tone: isDisabled ? 'muted' : 'subtle' }), children: description }))] }), meta && (0, jsx_runtime_1.jsx)("div", { className: "cim-select-item-slot", children: meta })] })) }));
162
150
  }
163
151
  SelectItem.displayName = 'SelectItem';
164
152
  /** Groups list items within `Select` into a section. */