@cimpress-ui/react 1.3.0 → 1.4.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 (87) hide show
  1. package/dist/commonjs/components/combo-box/combo-box.d.ts +1 -1
  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 -3
  4. package/dist/commonjs/components/combo-box/combo-box.js.map +1 -1
  5. package/dist/commonjs/components/internal/x-button/x-button.js +7 -2
  6. package/dist/commonjs/components/internal/x-button/x-button.js.map +1 -1
  7. package/dist/commonjs/components/pagination/link-pagination.js +2 -3
  8. package/dist/commonjs/components/pagination/link-pagination.js.map +1 -1
  9. package/dist/commonjs/components/tag-field/tag-field-list-box.js +3 -0
  10. package/dist/commonjs/components/tag-field/tag-field-list-box.js.map +1 -1
  11. package/dist/commonjs/components/tag-field/tag-field.d.ts +1 -1
  12. package/dist/commonjs/components/tag-field/tag-field.js +1 -1
  13. package/dist/commonjs/components/tag-field/tag-field.js.map +1 -1
  14. package/dist/commonjs/components/text-inputs/search-field.d.ts +12 -0
  15. package/dist/commonjs/components/text-inputs/search-field.d.ts.map +1 -0
  16. package/dist/commonjs/components/text-inputs/search-field.js +38 -0
  17. package/dist/commonjs/components/text-inputs/search-field.js.map +1 -0
  18. package/dist/commonjs/components/text-inputs/text-area.d.ts.map +1 -1
  19. package/dist/commonjs/components/text-inputs/text-area.js +3 -1
  20. package/dist/commonjs/components/text-inputs/text-area.js.map +1 -1
  21. package/dist/commonjs/components/text-inputs/text-field.d.ts +2 -2
  22. package/dist/commonjs/components/text-inputs/text-field.d.ts.map +1 -1
  23. package/dist/commonjs/components/text-inputs/text-field.js +6 -2
  24. package/dist/commonjs/components/text-inputs/text-field.js.map +1 -1
  25. package/dist/commonjs/components/types.js.map +1 -1
  26. package/dist/commonjs/i18n/messages/en-US.js +1 -1
  27. package/dist/commonjs/i18n/messages/en-US.js.map +1 -1
  28. package/dist/commonjs/i18n/messages/types.d.ts +2 -0
  29. package/dist/commonjs/i18n/messages/types.d.ts.map +1 -1
  30. package/dist/commonjs/i18n/messages/types.js.map +1 -1
  31. package/dist/commonjs/icons/close-circle.d.ts +8 -0
  32. package/dist/commonjs/icons/close-circle.d.ts.map +1 -0
  33. package/dist/commonjs/icons/close-circle.js +24 -0
  34. package/dist/commonjs/icons/close-circle.js.map +1 -0
  35. package/dist/commonjs/icons/index.d.ts +1 -0
  36. package/dist/commonjs/icons/index.d.ts.map +1 -1
  37. package/dist/commonjs/icons/index.js +4 -2
  38. package/dist/commonjs/icons/index.js.map +1 -1
  39. package/dist/commonjs/index.d.ts +3 -2
  40. package/dist/commonjs/index.d.ts.map +1 -1
  41. package/dist/commonjs/index.js +3 -2
  42. package/dist/commonjs/index.js.map +1 -1
  43. package/dist/esm/components/combo-box/combo-box.d.ts +1 -1
  44. package/dist/esm/components/combo-box/combo-box.d.ts.map +1 -1
  45. package/dist/esm/components/combo-box/combo-box.js +9 -3
  46. package/dist/esm/components/combo-box/combo-box.js.map +1 -1
  47. package/dist/esm/components/internal/x-button/x-button.js +8 -3
  48. package/dist/esm/components/internal/x-button/x-button.js.map +1 -1
  49. package/dist/esm/components/pagination/link-pagination.js +2 -3
  50. package/dist/esm/components/pagination/link-pagination.js.map +1 -1
  51. package/dist/esm/components/tag-field/tag-field-list-box.js +4 -1
  52. package/dist/esm/components/tag-field/tag-field-list-box.js.map +1 -1
  53. package/dist/esm/components/tag-field/tag-field.d.ts +1 -1
  54. package/dist/esm/components/tag-field/tag-field.js +1 -1
  55. package/dist/esm/components/tag-field/tag-field.js.map +1 -1
  56. package/dist/esm/components/text-inputs/search-field.d.ts +12 -0
  57. package/dist/esm/components/text-inputs/search-field.d.ts.map +1 -0
  58. package/dist/esm/components/text-inputs/search-field.js +32 -0
  59. package/dist/esm/components/text-inputs/search-field.js.map +1 -0
  60. package/dist/esm/components/text-inputs/text-area.d.ts.map +1 -1
  61. package/dist/esm/components/text-inputs/text-area.js +3 -1
  62. package/dist/esm/components/text-inputs/text-area.js.map +1 -1
  63. package/dist/esm/components/text-inputs/text-field.d.ts +2 -2
  64. package/dist/esm/components/text-inputs/text-field.d.ts.map +1 -1
  65. package/dist/esm/components/text-inputs/text-field.js +7 -3
  66. package/dist/esm/components/text-inputs/text-field.js.map +1 -1
  67. package/dist/esm/components/types.js.map +1 -1
  68. package/dist/esm/i18n/messages/en-US.js +1 -1
  69. package/dist/esm/i18n/messages/en-US.js.map +1 -1
  70. package/dist/esm/i18n/messages/types.d.ts +2 -0
  71. package/dist/esm/i18n/messages/types.d.ts.map +1 -1
  72. package/dist/esm/i18n/messages/types.js.map +1 -1
  73. package/dist/esm/icons/close-circle.d.ts +8 -0
  74. package/dist/esm/icons/close-circle.d.ts.map +1 -0
  75. package/dist/esm/icons/close-circle.js +19 -0
  76. package/dist/esm/icons/close-circle.js.map +1 -0
  77. package/dist/esm/icons/index.d.ts +1 -0
  78. package/dist/esm/icons/index.d.ts.map +1 -1
  79. package/dist/esm/icons/index.js +1 -0
  80. package/dist/esm/icons/index.js.map +1 -1
  81. package/dist/esm/index.d.ts +3 -2
  82. package/dist/esm/index.d.ts.map +1 -1
  83. package/dist/esm/index.js +3 -2
  84. package/dist/esm/index.js.map +1 -1
  85. package/dist-styles/core.css +1 -1
  86. package/dist-styles/styles.css +1 -1
  87. package/package.json +12 -12
@@ -17,7 +17,7 @@ export interface ComboBoxProps<T extends CollectionItem = CollectionItem> extend
17
17
  /**
18
18
  * Allows users to filter a collapsible list and select one item from it.
19
19
  *
20
- * See [combo box usage guidelines](https://ui.cimpress.com/components/combo-box)
20
+ * See [combo box usage guidelines](https://ui.cimpress.io/components/combo-box)
21
21
  */
22
22
  declare const _ComboBox: <T extends CollectionItem>(props: ComboBoxProps<T> & import("react").RefAttributes<HTMLDivElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
23
23
  export { _ComboBox as ComboBox };
@@ -1 +1 @@
1
- {"version":3,"file":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AY,GAAG,cAAc,GAAG,YAAY,CAAC;IACzF,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"}
1
+ {"version":3,"file":"combo-box.d.ts","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAKA,OAAO,EASL,KAAK,YAAY,IAAI,eAAe,EAOpC,KAAK,aAAa,IAAI,gBAAgB,EACtC,KAAK,gBAAgB,IAAI,mBAAmB,EAE7C,MAAM,uBAAuB,CAAC;AAU/B,OAAO,KAAK,EACV,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,SAAS,cAAc,GAAG,cAAc,CACtE,SAAQ,WAAW,EACjB,yBAAyB,CAAC,uBAAuB,CAAC,E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B;yBApBe,eAAe"}
@@ -10,6 +10,7 @@ exports.ComboBoxSection = ComboBoxSection;
10
10
  const jsx_runtime_1 = require("react/jsx-runtime");
11
11
  const clsx_1 = __importDefault(require("clsx"));
12
12
  const react_1 = require("react");
13
+ const react_aria_1 = require("react-aria");
13
14
  const react_aria_components_1 = require("react-aria-components");
14
15
  const forward_ref_js_1 = require("../../forward-ref.js");
15
16
  const index_js_1 = require("../../i18n/index.js");
@@ -38,14 +39,13 @@ function ComboBox({ label, description, error, items, children, placeholder, UNS
38
39
  if (!(0, is_production_js_1.isProduction)() && items != null && typeof children !== 'function') {
39
40
  console.warn('`ComboBox` requires `children` to be a function when using `items` prop');
40
41
  }
41
- const collectionMessages = (0, index_js_1.useLocalizedMessages)('UNSTABLE_collection');
42
- const listBox = ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ListBox, { className: "cim-combo-box-listbox", onScroll: onScroll, renderEmptyState: () => isLoading ? (0, jsx_runtime_1.jsx)(spinner_js_1.Spinner, { "aria-label": collectionMessages.format('loading'), size: "small", marginY: 8 }) : null, 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('loadingMore'), size: "small", marginY: 8 }) })] }));
42
+ const listBox = ((0, jsx_runtime_1.jsx)(ComboBoxList, { items: items, isLoading: isLoading, onLoadMore: onLoadMore, onScroll: onScroll, children: children }));
43
43
  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, menuTrigger: "focus", isReadOnly: isReadOnly, "data-readonly": isReadOnly ? true : 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, { isReadOnly: isReadOnly, placeholder: placeholder }), (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) })] }));
44
44
  }
45
45
  /**
46
46
  * Allows users to filter a collapsible list and select one item from it.
47
47
  *
48
- * See [combo box usage guidelines](https://ui.cimpress.com/components/combo-box)
48
+ * See [combo box usage guidelines](https://ui.cimpress.io/components/combo-box)
49
49
  */
50
50
  const _ComboBox = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(ComboBox), 'ComboBox');
51
51
  exports.ComboBox = _ComboBox;
@@ -56,6 +56,12 @@ function ComboBoxInput({ isReadOnly, placeholder, }) {
56
56
  // By default, React Aria only opens the popover when the input is focused.
57
57
  onClick: () => !isReadOnly && comboBoxState.open(), placeholder: placeholder }));
58
58
  }
59
+ function ComboBoxList({ items, children, isLoading, onLoadMore, onScroll, }) {
60
+ const comboBoxState = (0, react_1.useContext)(react_aria_components_1.ComboBoxStateContext);
61
+ const collectionMessages = (0, index_js_1.useLocalizedMessages)('UNSTABLE_collection');
62
+ (0, react_aria_1.usePreventScroll)({ isDisabled: !comboBoxState?.isOpen });
63
+ return ((0, jsx_runtime_1.jsxs)(react_aria_components_1.ListBox, { className: "cim-combo-box-listbox", onScroll: onScroll, renderEmptyState: () => isLoading ? (0, jsx_runtime_1.jsx)(spinner_js_1.Spinner, { "aria-label": collectionMessages.format('loading'), size: "small", marginY: 8 }) : null, 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('loadingMore'), size: "small", marginY: 8 }) })] }));
64
+ }
59
65
  /** Renders a single list item within `ComboBox`. */
60
66
  function ComboBoxItem({ children, ...props }) {
61
67
  const textValue = typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');
@@ -1 +1 @@
1
- {"version":3,"file":"combo-box.js","sourceRoot":"","sources":["../../../../src/components/combo-box/combo-box.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAmNb,oCAiBC;AAYD,0CAoBC;;AAlQD,gDAAwB;AACxB,iCAAsD;AACtD,iEAmB+B;AAC/B,yDAAkD;AAClD,kDAA2D;AAC3D,mDAAkE;AAClE,mEAA4D;AAC5D,qFAA6E;AAC7E,mEAA2D;AAC3D,0FAAmF;AACnF,wEAA4G;AAC5G,sDAAgD;AAUhD,qDAAmD;AAEnD,MAAM,sBAAsB,GAAyB;IACnD,SAAS,EAAE,EAAE;IACb,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,EAAE;IAChB,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,CAAC;CACP,CAAC;AAwCF,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,SAAS,EAC7B,mBAAmB,EAAE,UAAU,EAC/B,GAAG,KAAK,EACS,EACnB,GAAiC;IAEjC,MAAM,EAAE,YAAY,EAAE,SAAS,EAA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,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 { useContext, type ForwardedRef } from 'react';\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 type ListBoxProps as RACListBoxProps,\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 { IconCheck, 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 { Spinner } from '../spinner/spinner.js';\nimport type {\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 rowHeight: 40,\n headingHeight: 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 CommonProps,\n FieldWithPlaceholderProps<ComboBoxValidationValue>,\n CollectionProps<T>,\n AsyncItemLoadingProps,\n Pick<\n RACComboBoxProps<T>,\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'selectedKey'\n | 'defaultSelectedKey'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onSelectionChange'\n | 'onInputChange'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n >,\n Pick<RACListBoxProps<T>, 'onScroll'> {\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}\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 ...props\n }: ComboBoxProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\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 const collectionMessages = useLocalizedMessages('UNSTABLE_collection');\n\n const listBox = (\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 return (\n <RACComboBox\n {...props}\n ref={ref}\n className={clsx('cim-combo-box', UNSAFE_className)}\n style={UNSAFE_style}\n menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n >\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-combo-box-input-group\">\n <ComboBoxInput isReadOnly={isReadOnly} placeholder={placeholder} />\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.com/components/combo-box)\n */\nconst _ComboBox = withStyleProps(forwardRef(ComboBox), 'ComboBox');\n\nexport { _ComboBox as ComboBox };\n\nfunction ComboBoxInput({\n isReadOnly,\n placeholder,\n}: {\n isReadOnly: boolean | undefined;\n placeholder: string | undefined;\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n\n return (\n <RACInput\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 />\n );\n}\n\nexport interface ComboBoxItemProps<T extends CollectionItem>\n extends Pick<RACListBoxItemProps<T>, 'id' | 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\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 <IconCheck />\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;;;;;;;AAwOb,oCAiBC;AAYD,0CAoBC;;AAvRD,gDA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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 { useContext, type ForwardedRef } 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 type ListBoxProps as RACListBoxProps,\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 { IconCheck, 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 { Spinner } from '../spinner/spinner.js';\nimport type {\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 rowHeight: 40,\n headingHeight: 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 CommonProps,\n FieldWithPlaceholderProps<ComboBoxValidationValue>,\n CollectionProps<T>,\n AsyncItemLoadingProps,\n Pick<\n RACComboBoxProps<T>,\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'selectedKey'\n | 'defaultSelectedKey'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onSelectionChange'\n | 'onInputChange'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n >,\n Pick<RACListBoxProps<T>, 'onScroll'> {\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}\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 ...props\n }: ComboBoxProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\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 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 menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n >\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-combo-box-input-group\">\n <ComboBoxInput isReadOnly={isReadOnly} placeholder={placeholder} />\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 ComboBoxInput({\n isReadOnly,\n placeholder,\n}: {\n isReadOnly: boolean | undefined;\n placeholder: string | undefined;\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n\n return (\n <RACInput\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 />\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>\n extends Pick<RACListBoxItemProps<T>, 'id' | 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\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 <IconCheck />\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"]}
@@ -8,10 +8,15 @@ const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const clsx_1 = __importDefault(require("clsx"));
9
9
  const react_aria_components_1 = require("react-aria-components");
10
10
  const index_js_1 = require("../../../icons/index.js");
11
+ const ICON_MAP = {
12
+ standard: index_js_1.IconCloseBold,
13
+ circled: index_js_1.IconCloseCircle,
14
+ };
11
15
  /**
12
16
  * @internal
13
17
  */
14
- function XButton({ size = 'medium', variant = 'square', UNSAFE_className, UNSAFE_style, ...props }) {
15
- return ((0, jsx_runtime_1.jsx)(react_aria_components_1.Button, { ...props, className: (0, clsx_1.default)('cim-x-button', UNSAFE_className), style: UNSAFE_style, "data-size": size, "data-variant": variant, children: (0, jsx_runtime_1.jsx)(index_js_1.IconCloseBold, {}) }));
18
+ function XButton({ size = 'medium', variant = 'square', iconType = 'standard', UNSAFE_className, UNSAFE_style, ...props }) {
19
+ const Icon = ICON_MAP[iconType];
20
+ return ((0, jsx_runtime_1.jsx)(react_aria_components_1.Button, { ...props, className: (0, clsx_1.default)('cim-x-button', UNSAFE_className), style: UNSAFE_style, "data-size": size, "data-variant": variant, children: (0, jsx_runtime_1.jsx)(Icon, {}) }));
16
21
  }
17
22
  //# sourceMappingURL=x-button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"x-button.js","sourceRoot":"","sources":["../../../../../src/components/internal/x-button/x-button.tsx"],"names":[],"mappings":";;;;;AAcA,0BAkBC;;AAhCD,gDAAwB;AACxB,iEAAgG;AAChG,sDAAwD;AASxD;;GAEG;AACH,SAAgB,OAAO,CAAC,EACtB,IAAI,GAAG,QAAQ,EACf,OAAO,GAAG,QAAQ,EAClB,gBAAgB,EAChB,YAAY,EACZ,GAAG,KAAK,EACK;IACb,OAAO,CACL,uBAAC,8BAAS,OACJ,KAAK,EACT,SAAS,EAAE,IAAA,cAAI,EAAC,cAAc,EAAE,gBAAgB,CAAC,EACjD,KAAK,EAAE,YAAY,eACR,IAAI,kBACD,OAAO,YAErB,uBAAC,wBAAa,KAAG,GACP,CACb,CAAC;AACJ,CAAC","sourcesContent":["import clsx from 'clsx';\nimport { type ButtonProps as RACButtonProps, Button as RACButton } from 'react-aria-components';\nimport { IconCloseBold } from '../../../icons/index.js';\nimport type { CommonProps } from '../../types.js';\n\ninterface XButtonProps extends CommonProps, Pick<RACButtonProps, 'onPress' | 'slot'> {\n 'aria-label': string;\n size?: 'small' | 'medium';\n variant?: 'circle' | 'square';\n}\n\n/**\n * @internal\n */\nexport function XButton({\n size = 'medium',\n variant = 'square',\n UNSAFE_className,\n UNSAFE_style,\n ...props\n}: XButtonProps) {\n return (\n <RACButton\n {...props}\n className={clsx('cim-x-button', UNSAFE_className)}\n style={UNSAFE_style}\n data-size={size}\n data-variant={variant}\n >\n <IconCloseBold />\n </RACButton>\n );\n}\n"]}
1
+ {"version":3,"file":"x-button.js","sourceRoot":"","sources":["../../../../../src/components/internal/x-button/x-button.tsx"],"names":[],"mappings":";;;;;AAwBA,0BAqBC;;AA7CD,gDAAwB;AAExB,iEAAgG;AAChG,sDAAyE;AAazE,MAAM,QAAQ,GAAqF;IACjG,QAAQ,EAAE,wBAAa;IACvB,OAAO,EAAE,0BAAe;CACzB,CAAC;AAEF;;GAEG;AACH,SAAgB,OAAO,CAAC,EACtB,IAAI,GAAG,QAAQ,EACf,OAAO,GAAG,QAAQ,EAClB,QAAQ,GAAG,UAAU,EACrB,gBAAgB,EAChB,YAAY,EACZ,GAAG,KAAK,EACK;IACb,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEhC,OAAO,CACL,uBAAC,8BAAS,OACJ,KAAK,EACT,SAAS,EAAE,IAAA,cAAI,EAAC,cAAc,EAAE,gBAAgB,CAAC,EACjD,KAAK,EAAE,YAAY,eACR,IAAI,kBACD,OAAO,YAErB,uBAAC,IAAI,KAAG,GACE,CACb,CAAC;AACJ,CAAC","sourcesContent":["import clsx from 'clsx';\nimport type { JSX } from 'react';\nimport { type ButtonProps as RACButtonProps, Button as RACButton } from 'react-aria-components';\nimport { IconCloseBold, IconCloseCircle } from '../../../icons/index.js';\nimport type { CommonProps, IconProps } from '../../types.js';\n\ninterface XButtonProps extends CommonProps, Pick<RACButtonProps, 'isDisabled' | 'onPress' | 'slot'> {\n 'aria-label': string;\n /** @default 'medium' */\n size?: 'small' | 'medium';\n /** @default 'square' */\n variant?: 'circle' | 'square';\n /** @default 'standard' */\n iconType?: 'standard' | 'circled';\n}\n\nconst ICON_MAP: Record<NonNullable<XButtonProps['iconType']>, (props: IconProps) => JSX.Element> = {\n standard: IconCloseBold,\n circled: IconCloseCircle,\n};\n\n/**\n * @internal\n */\nexport function XButton({\n size = 'medium',\n variant = 'square',\n iconType = 'standard',\n UNSAFE_className,\n UNSAFE_style,\n ...props\n}: XButtonProps) {\n const Icon = ICON_MAP[iconType];\n\n return (\n <RACButton\n {...props}\n className={clsx('cim-x-button', UNSAFE_className)}\n style={UNSAFE_style}\n data-size={size}\n data-variant={variant}\n >\n <Icon />\n </RACButton>\n );\n}\n"]}
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LinkPagination = LinkPagination;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const focus_1 = require("@react-aria/focus");
6
5
  const utils_1 = require("@react-aria/utils");
7
6
  const react_1 = require("react");
8
7
  const router_provider_js_1 = require("../../providers/router/router-provider.js");
@@ -34,11 +33,11 @@ hrefLang, target, download, ping, referrerPolicy, rel, routerOptions, ...props }
34
33
  const element = listRef.current.querySelector(`[href='${path}']${paginationPrevious ? '[data-previous]' : ':not([data-previous])'}${paginationNext ? '[data-next]' : ':not([data-next])'}`);
35
34
  if (paginationPrevious && currentPage === 2) {
36
35
  // "Previous" link will become disabled, so move focus to the first page link
37
- (0, focus_1.focusSafely)(listRef.current?.querySelector(`[href][data-first]`));
36
+ listRef.current?.querySelector(`[href][data-first]`)?.focus();
38
37
  }
39
38
  else if (paginationNext && currentPage === pageCount - 1) {
40
39
  // "Next" link will become disabled, so move focus to the last page link
41
- (0, focus_1.focusSafely)(listRef.current?.querySelector(`[href][data-last]`));
40
+ listRef.current?.querySelector(`[href][data-last]`)?.focus();
42
41
  }
43
42
  onPageChange?.(Number(element.dataset.page));
44
43
  // We don't have access to the modifiers of the original event.
@@ -1 +1 @@
1
- {"version":3,"file":"link-pagination.js","sourceRoot":"","sources":["../../../../src/components/pagination/link-pagination.tsx"],"names":[],"mappings":";;AA0BA,wCAoHC;;AA9ID,6CAAgD;AAChD,6CAA8C;AAC9C,iCAA+D;AAC/D,kFAA2E;AAC3E,uEAA+D;AAC/D,6DAAsD;AAEtD,6DAAgF;AAkBhF,gBAAgB;AAChB,SAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,SAAS,EACT,IAAI,EACJ,YAAY;AAEZ,mBAAmB;AACnB,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,cAAc,EACd,GAAG,EACH,aAAa,EAEb,GAAG,KAAK,EACY;IACpB,MAAM,MAAM,GAAG,IAAA,iBAAS,GAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAA,cAAM,EAAmB,IAAI,CAAC,CAAC;IAE/C,MAAM,eAAe,GAAG;QACtB,QAAQ;QACR,MAAM;QACN,QAAQ;QACR,IAAI;QACJ,cAAc;QACd,GAAG;QACH,aAAa;KACd,CAAC;IAEF,MAAM,qBAAqB,GAAG,IAAA,mBAAW,EACvC,CAAC,IAAU,EAAE,aAA6B,EAAE,EAAE;QAC5C,mEAAmE;QACnE,wDAAwD;QAExD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,GACzC,aAAqD,EAAE,0BAA0B,IAAI,EAAE,CAAC;QAE3F,MAAM,OAAO,GAAG,OAAO,CAAC,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AAE;wBAC1B,kBAAkB,EAAE,IAAI;qBACzB;iBAC0C,sCAGpC,WAAW,GAAG,CAAC,GAC1B,CACH,EACD,gBAAgB,EAAE,CAAC,eAAe,EAAE,EAAE,CAAC,CACrC,uBAAC,oCAAc,OACT,eAAe,KACf,eAAe,EACnB,IAAI,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,EAC3B,aAAa,EACX;oBACE,GAAG,CAAC,eAAe,CAAC,aAAa,IAAI,EAAE,CAAC;oBACxC,0BAA0B,EAAE;wBAC1B,cAAc,EAAE,IAAI;qBACrB;iBAC0C,kCAGpC,WAAW,GAAG,CAAC,GAC1B,CACH,EACD,gBAAgB,EAAE,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CACpE,uBAAC,2BAAU,OACL,eAAe,KACf,eAAe,kBACL,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAChD,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,eACX,UAAU,GACrB,CACH,GACD,GACa,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { focusSafely } from '@react-aria/focus';\nimport { useRouter } from '@react-aria/utils';\nimport { type ForwardedRef, useCallback, useRef } from 'react';\nimport { RouterProvider } from '../../providers/router/router-provider.js';\nimport { IconLinkButton } from '../button/icon-link-button.js';\nimport { LinkButton } from '../button/link-button.js';\nimport type { FocusableElement, Href, NavigationProps, RouterOptions } from '../types.js';\nimport { BasePagination, type BasePaginationProps } from './base-pagination.js';\n\ninterface PaginationRouterOptions {\n __INTERNAL__CIMPRESS__UI__?: {\n paginationPrevious?: boolean;\n paginationNext?: boolean;\n };\n}\n\n/** @internal */\nexport interface LinkPaginationProps extends BasePaginationProps, Omit<NavigationProps, 'href'> {\n navRef?: ForwardedRef<HTMLElement>;\n /** A callback function that is called when the page number changes. */\n onPageChange?: (page: number) => void;\n /** A function that returns a URL for a given page number. */\n href: (page: number) => string;\n}\n\n/** @internal */\nexport function LinkPagination({\n currentPage,\n pageCount,\n href,\n onPageChange,\n\n // Navigation props\n hrefLang,\n target,\n download,\n ping,\n referrerPolicy,\n rel,\n routerOptions,\n\n ...props\n}: LinkPaginationProps) {\n const router = useRouter();\n const listRef = useRef<HTMLUListElement>(null);\n\n const navigationProps = {\n hrefLang,\n target,\n download,\n ping,\n referrerPolicy,\n rel,\n routerOptions,\n };\n\n const navigationInterceptor = useCallback(\n (path: Href, routerOptions?: RouterOptions) => {\n // If navigation would cause the activated link to become disabled,\n // we have to move focus to a different link beforehand.\n\n if (!listRef.current) {\n return;\n }\n\n const { paginationPrevious, paginationNext } =\n (routerOptions as PaginationRouterOptions | undefined)?.__INTERNAL__CIMPRESS__UI__ ?? {};\n\n const element = listRef.current.querySelector(\n `[href='${path}']${paginationPrevious ? '[data-previous]' : ':not([data-previous])'}${paginationNext ? '[data-next]' : ':not([data-next])'}`,\n )!;\n\n if (paginationPrevious && currentPage === 2) {\n // \"Previous\" link will become disabled, so move focus to the first page link\n focusSafely(listRef.current?.querySelector(`[href][data-first]`) as FocusableElement);\n } else if (paginationNext && currentPage === pageCount - 1) {\n // \"Next\" link will become disabled, so move focus to the last page link\n focusSafely(listRef.current?.querySelector(`[href][data-last]`) as FocusableElement);\n }\n\n onPageChange?.(Number((element as HTMLElement).dataset.page));\n\n // We don't have access to the modifiers of the original event.\n // However, this function wouldn't run if the original modifiers impacted routing, so it is safe to pass an empty object.\n router.open(element, {}, path, routerOptions);\n },\n [router, currentPage, pageCount, onPageChange],\n );\n\n return (\n <RouterProvider navigate={navigationInterceptor}>\n <BasePagination\n {...props}\n listRef={listRef}\n currentPage={currentPage}\n pageCount={pageCount}\n renderPreviousButton={(previousButtonProps) => (\n <IconLinkButton\n {...navigationProps}\n {...previousButtonProps}\n href={href(currentPage - 1)}\n routerOptions={\n {\n ...(navigationProps.routerOptions ?? {}),\n __INTERNAL__CIMPRESS__UI__: {\n paginationPrevious: true,\n },\n } as PaginationRouterOptions as RouterOptions\n }\n data-previous\n data-page={currentPage - 1}\n />\n )}\n renderNextButton={(nextButtonProps) => (\n <IconLinkButton\n {...navigationProps}\n {...nextButtonProps}\n href={href(currentPage + 1)}\n routerOptions={\n {\n ...(navigationProps.routerOptions ?? {}),\n __INTERNAL__CIMPRESS__UI__: {\n paginationNext: true,\n },\n } as PaginationRouterOptions as RouterOptions\n }\n data-next\n data-page={currentPage + 1}\n />\n )}\n renderPageButton={({ pageNumber, isCurrentPage, pageButtonProps }) => (\n <LinkButton\n {...navigationProps}\n {...pageButtonProps}\n aria-current={isCurrentPage ? 'page' : undefined}\n href={href(pageNumber)}\n data-page={pageNumber}\n />\n )}\n />\n </RouterProvider>\n );\n}\n"]}
1
+ {"version":3,"file":"link-pagination.js","sourceRoot":"","sources":["../../../../src/components/pagination/link-pagination.tsx"],"names":[],"mappings":";;AAyBA,wCAoHC;;AA7ID,6CAA8C;AAC9C,iCAA+D;AAC/D,kFAA2E;AAC3E,uEAA+D;AAC/D,6DAAsD;AAEtD,6DAAgF;AAkBhF,gBAAgB;AAChB,SAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,SAAS,EACT,IAAI,EACJ,YAAY;AAEZ,mBAAmB;AACnB,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,cAAc,EACd,GAAG,EACH,aAAa,EAEb,GAAG,KAAK,EACY;IACpB,MAAM,MAAM,GAAG,IAAA,iBAAS,GAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,IAAA,cAAM,EAAmB,IAAI,CAAC,CAAC;IAE/C,MAAM,eAAe,GAAG;QACtB,QAAQ;QACR,MAAM;QACN,QAAQ;QACR,IAAI;QACJ,cAAc;QACd,GAAG;QACH,aAAa;KACd,CAAC;IAEF,MAAM,qBAAqB,GAAG,IAAA,mBAAW,EACvC,CAAC,IAAU,EAAE,aAA6B,EAAE,EAAE;QAC5C,mEAAmE;QACnE,wDAAwD;QAExD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,C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B,IAAI,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,EAC3B,aAAa,EACX;oBACE,GAAG,CAAC,eAAe,CAAC,aAAa,IAAI,EAAE,CAAC;oBACxC,0BAA0B,EAAE;wBAC1B,kBAAkB,EAAE,IAAI;qBACzB;iBAC0C,sCAGpC,WAAW,GAAG,CAAC,GAC1B,CACH,EACD,gBAAgB,EAAE,CAAC,eAAe,EAAE,EAAE,CAAC,CACrC,uBAAC,oCAAc,OACT,eAAe,KACf,eAAe,EACnB,IAAI,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,EAC3B,aAAa,EACX;oBACE,GAAG,CAAC,eAAe,CAAC,aAAa,IAAI,EAAE,CAAC;oBACxC,0BAA0B,EAAE;wBAC1B,cAAc,EAAE,IAAI;qBACrB;iBAC0C,kCAGpC,WAAW,GAAG,CAAC,GAC1B,CACH,EACD,gBAAgB,EAAE,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CACpE,uBAAC,2BAAU,OACL,eAAe,KACf,eAAe,kBACL,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAChD,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,eACX,UAAU,GACrB,CACH,GACD,GACa,CAClB,CAAC;AACJ,CAAC","sourcesContent":["import { useRouter } from '@react-aria/utils';\nimport { type ForwardedRef, useCallback, useRef } from 'react';\nimport { RouterProvider } from '../../providers/router/router-provider.js';\nimport { IconLinkButton } from '../button/icon-link-button.js';\nimport { LinkButton } from '../button/link-button.js';\nimport type { FocusableElement, Href, NavigationProps, RouterOptions } from '../types.js';\nimport { BasePagination, type BasePaginationProps } from './base-pagination.js';\n\ninterface PaginationRouterOptions {\n __INTERNAL__CIMPRESS__UI__?: {\n paginationPrevious?: boolean;\n paginationNext?: boolean;\n };\n}\n\n/** @internal */\nexport interface LinkPaginationProps extends BasePaginationProps, Omit<NavigationProps, 'href'> {\n navRef?: ForwardedRef<HTMLElement>;\n /** A callback function that is called when the page number changes. */\n onPageChange?: (page: number) => void;\n /** A function that returns a URL for a given page number. */\n href: (page: number) => string;\n}\n\n/** @internal */\nexport function LinkPagination({\n currentPage,\n pageCount,\n href,\n onPageChange,\n\n // Navigation props\n hrefLang,\n target,\n download,\n ping,\n referrerPolicy,\n rel,\n routerOptions,\n\n ...props\n}: LinkPaginationProps) {\n const router = useRouter();\n const listRef = useRef<HTMLUListElement>(null);\n\n const navigationProps = {\n hrefLang,\n target,\n download,\n ping,\n referrerPolicy,\n rel,\n routerOptions,\n };\n\n const navigationInterceptor = useCallback(\n (path: Href, routerOptions?: RouterOptions) => {\n // If navigation would cause the activated link to become disabled,\n // we have to move focus to a different link beforehand.\n\n if (!listRef.current) {\n return;\n }\n\n const { paginationPrevious, paginationNext } =\n (routerOptions as PaginationRouterOptions | undefined)?.__INTERNAL__CIMPRESS__UI__ ?? {};\n\n const element = listRef.current.querySelector(\n `[href='${path}']${paginationPrevious ? '[data-previous]' : ':not([data-previous])'}${paginationNext ? '[data-next]' : ':not([data-next])'}`,\n )!;\n\n if (paginationPrevious && currentPage === 2) {\n // \"Previous\" link will become disabled, so move focus to the first page link\n (listRef.current?.querySelector(`[href][data-first]`) as FocusableElement | undefined)?.focus();\n } else if (paginationNext && currentPage === pageCount - 1) {\n // \"Next\" link will become disabled, so move focus to the last page link\n (listRef.current?.querySelector(`[href][data-last]`) as FocusableElement | undefined)?.focus();\n }\n\n onPageChange?.(Number((element as HTMLElement).dataset.page));\n\n // We don't have access to the modifiers of the original event.\n // However, this function wouldn't run if the original modifiers impacted routing, so it is safe to pass an empty object.\n router.open(element, {}, path, routerOptions);\n },\n [router, currentPage, pageCount, onPageChange],\n );\n\n return (\n <RouterProvider navigate={navigationInterceptor}>\n <BasePagination\n {...props}\n listRef={listRef}\n currentPage={currentPage}\n pageCount={pageCount}\n renderPreviousButton={(previousButtonProps) => (\n <IconLinkButton\n {...navigationProps}\n {...previousButtonProps}\n href={href(currentPage - 1)}\n routerOptions={\n {\n ...(navigationProps.routerOptions ?? {}),\n __INTERNAL__CIMPRESS__UI__: {\n paginationPrevious: true,\n },\n } as PaginationRouterOptions as RouterOptions\n }\n data-previous\n data-page={currentPage - 1}\n />\n )}\n renderNextButton={(nextButtonProps) => (\n <IconLinkButton\n {...navigationProps}\n {...nextButtonProps}\n href={href(currentPage + 1)}\n routerOptions={\n {\n ...(navigationProps.routerOptions ?? {}),\n __INTERNAL__CIMPRESS__UI__: {\n paginationNext: true,\n },\n } as PaginationRouterOptions as RouterOptions\n }\n data-next\n data-page={currentPage + 1}\n />\n )}\n renderPageButton={({ pageNumber, isCurrentPage, pageButtonProps }) => (\n <LinkButton\n {...navigationProps}\n {...pageButtonProps}\n aria-current={isCurrentPage ? 'page' : undefined}\n href={href(pageNumber)}\n data-page={pageNumber}\n />\n )}\n />\n </RouterProvider>\n );\n}\n"]}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TagFieldListBox = TagFieldListBox;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
+ const react_aria_1 = require("react-aria");
6
7
  const react_aria_components_1 = require("react-aria-components");
7
8
  const VIRTUAL_LAYOUT_OPTIONS = {
8
9
  rowHeight: 36,
@@ -12,7 +13,9 @@ const VIRTUAL_LAYOUT_OPTIONS = {
12
13
  };
13
14
  /** @internal */
14
15
  function TagFieldListBox({ children, inputId, selectedKeys, setSelectedKeys, items, onScroll, isVirtualized, }) {
16
+ const comboBoxState = (0, react_1.useContext)(react_aria_components_1.ComboBoxStateContext);
15
17
  const listState = (0, react_1.useContext)(react_aria_components_1.ListStateContext);
18
+ (0, react_aria_1.usePreventScroll)({ isDisabled: !comboBoxState?.isOpen });
16
19
  // Override RACListStateContext to allow multiple selection within the list
17
20
  const updatedListState = (0, react_1.useMemo)(() => {
18
21
  if (!listState || !listState.selectionManager) {
@@ -1 +1 @@
1
- {"version":3,"file":"tag-field-list-box.js","sourceRoot":"","sources":["../../../../src/components/tag-field/tag-field-list-box.tsx"],"names":[],"mappings":";;AAmBA,0CAgEC;;AAnFD,iCAA4C;AAC5C,iEAM+B;AAI/B,MAAM,sBAAsB,GAAyB;IACnD,SAAS,EAAE,EAAE;IACb,aAAa,EAAE,EAAE;IACjB,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,CAAC;CACP,CAAC;AAEF,gBAAgB;AAChB,SAAgB,eAAe,CAA2B,EACxD,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,eAAe,EACf,KAAK,EACL,QAAQ,EACR,aAAa,GAKd;IACC,MAAM,SAAS,GAAG,IAAA,kBAAU,EAAC,wCAAmB,CAAC,CAAC;IAElD,2EAA2E;IAC3E,MAAM,gBAAgB,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QACpC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC;YAC9C,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,uDAAuD;QACvD,wEAAwE;QACxE,sDAAsD;QACtD,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,aAAa,GAAG,UAAU,CAAC;QAC5D,uDAAuD;QACvD,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,YAAY,GAAG,YAAY,CAAC;QAC7D,uDAAuD;QACvD,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,eAAe,GAAG,CAAC,IAAsB,EAAE,EAAE;YAC5E,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;gBACnB,kGAAkG;gBAClG,uFAAuF;gBACvF,iFAAiF;gBACjF,yEAAyE;gBACxE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAA6B,EAAE,MAAM,EAAE,CAAC;YAC1E,CAAC;iBAAM,CAAC;gBACN,eAAe,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;QACH,CAAC,CAAC;QACF,uDAAuD;QACvD,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,sBAAsB,GAAG,KAAK,CAAC;QAEhE,OAAO;YACL,GAAG,SAAS;SACb,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;IAExD,MAAM,OAAO,GAAG,CACd,uBAAC,+BAAU,IAAC,SAAS,EAAC,uBAAuB,EAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,YAC3E,QAAQ,GACE,CACd,CAAC;IAEF,OAAO,CACL,uBAAC,wCAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,gBAAgB,YAClD,aAAa,CAAC,CAAC,CAAC,CACf,uBAAC,mCAAc,IAAC,MAAM,EAAE,kCAAa,EAAE,aAAa,EAAE,sBAAsB,YACzE,OAAO,GACO,CAClB,CAAC,CAAC,CAAC,CACF,OAAO,CACR,GAC4B,CAChC,CAAC;AACJ,CAAC","sourcesContent":["import { useContext, useMemo } from 'react';\nimport {\n ListBox as RACListBox,\n ListLayout as RACListLayout,\n type ListLayoutOptions as RACListLayoutOptions,\n ListStateContext as RACListStateContext,\n Virtualizer as RACVirtualizer,\n} from 'react-aria-components';\nimport type { CollectionItem, Key } from '../types.js';\nimport type { TagFieldProps } from './tag-field.js';\n\nconst VIRTUAL_LAYOUT_OPTIONS: RACListLayoutOptions = {\n rowHeight: 36,\n headingHeight: 32,\n padding: 0,\n gap: 0,\n};\n\n/** @internal */\nexport function TagFieldListBox<T extends CollectionItem>({\n children,\n inputId,\n selectedKeys,\n setSelectedKeys,\n items,\n onScroll,\n isVirtualized,\n}: Pick<TagFieldProps<T>, 'children' | 'items' | 'onScroll' | 'isVirtualized'> & {\n inputId: string;\n selectedKeys: Set<Key>;\n setSelectedKeys: (keys: Set<Key>) => void;\n}) {\n const listState = useContext(RACListStateContext);\n\n // Override RACListStateContext to allow multiple selection within the list\n const updatedListState = useMemo(() => {\n if (!listState || !listState.selectionManager) {\n return listState;\n }\n\n // @ts-expect-error `selectionManager.state` is private\n // This is a temporary mutation before a context update, so this is fine\n // eslint-disable-next-line react-hooks/react-compiler\n listState.selectionManager.state.selectionMode = 'multiple';\n // @ts-expect-error `selectionManager.state` is private\n listState.selectionManager.state.selectedKeys = selectedKeys;\n // @ts-expect-error `selectionManager.state` is private\n listState.selectionManager.state.setSelectedKeys = (keys: Set<Key> | 'all') => {\n if (keys === 'all') {\n // When the end-user presses Ctrl/Cmd + A on a list which has `selectionMode` set to `'multiple'`,\n // the selection manager emits the `'all'` string as an indication to select all items.\n // We don't want to do that - instead, we select the contents of the input field.\n // Querying by ID because RACInputContext has a null ref for some reason.\n (document.getElementById(inputId) as HTMLInputElement | null)?.select();\n } else {\n setSelectedKeys(keys);\n }\n };\n // @ts-expect-error `selectionManager.state` is private\n listState.selectionManager.state.disallowEmptySelection = false;\n\n return {\n ...listState,\n };\n }, [listState, selectedKeys, setSelectedKeys, inputId]);\n\n const listBox = (\n <RACListBox className=\"cim-combo-box-listbox\" onScroll={onScroll} items={items}>\n {children}\n </RACListBox>\n );\n\n return (\n <RACListStateContext.Provider value={updatedListState}>\n {isVirtualized ? (\n <RACVirtualizer layout={RACListLayout} layoutOptions={VIRTUAL_LAYOUT_OPTIONS}>\n {listBox}\n </RACVirtualizer>\n ) : (\n listBox\n )}\n </RACListStateContext.Provider>\n );\n}\n"]}
1
+ {"version":3,"file":"tag-field-list-box.js","sourceRoot":"","sources":["../../../../src/components/tag-field/tag-field-list-box.tsx"],"names":[],"mappings":";;AAqBA,0CAmEC;;AAxFD,iCAA4C;AAC5C,2CAA8C;AAC9C,iEAO+B;AAI/B,MAAM,sBAAsB,GAAyB;IACnD,SAAS,EAAE,EAAE;IACb,aAAa,EAAE,EAAE;IACjB,OAAO,EAAE,CAAC;IACV,GAAG,EAAE,CAAC;CACP,CAAC;AAEF,gBAAgB;AAChB,SAAgB,eAAe,CAA2B,EACxD,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,eAAe,EACf,KAAK,EACL,QAAQ,EAC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EAAC,uBAAuB,EAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,YAC3E,QAAQ,GACE,CACd,CAAC;IAEF,OAAO,CACL,uBAAC,wCAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,gBAAgB,YAClD,aAAa,CAAC,CAAC,CAAC,CACf,uBAAC,mCAAc,IAAC,MAAM,EAAE,kCAAa,EAAE,aAAa,EAAE,sBAAsB,YACzE,OAAO,GACO,CAClB,CAAC,CAAC,CAAC,CACF,OAAO,CACR,GAC4B,CAChC,CAAC;AACJ,CAAC","sourcesContent":["import { useContext, useMemo } from 'react';\nimport { usePreventScroll } from 'react-aria';\nimport {\n ComboBoxStateContext as RACComboBoxStateContext,\n ListBox as RACListBox,\n ListLayout as RACListLayout,\n type ListLayoutOptions as RACListLayoutOptions,\n ListStateContext as RACListStateContext,\n Virtualizer as RACVirtualizer,\n} from 'react-aria-components';\nimport type { CollectionItem, Key } from '../types.js';\nimport type { TagFieldProps } from './tag-field.js';\n\nconst VIRTUAL_LAYOUT_OPTIONS: RACListLayoutOptions = {\n rowHeight: 36,\n headingHeight: 32,\n padding: 0,\n gap: 0,\n};\n\n/** @internal */\nexport function TagFieldListBox<T extends CollectionItem>({\n children,\n inputId,\n selectedKeys,\n setSelectedKeys,\n items,\n onScroll,\n isVirtualized,\n}: Pick<TagFieldProps<T>, 'children' | 'items' | 'onScroll' | 'isVirtualized'> & {\n inputId: string;\n selectedKeys: Set<Key>;\n setSelectedKeys: (keys: Set<Key>) => void;\n}) {\n const comboBoxState = useContext(RACComboBoxStateContext);\n const listState = useContext(RACListStateContext);\n\n usePreventScroll({ isDisabled: !comboBoxState?.isOpen });\n\n // Override RACListStateContext to allow multiple selection within the list\n const updatedListState = useMemo(() => {\n if (!listState || !listState.selectionManager) {\n return listState;\n }\n\n // @ts-expect-error `selectionManager.state` is private\n // This is a temporary mutation before a context update, so this is fine\n // eslint-disable-next-line react-hooks/react-compiler\n listState.selectionManager.state.selectionMode = 'multiple';\n // @ts-expect-error `selectionManager.state` is private\n listState.selectionManager.state.selectedKeys = selectedKeys;\n // @ts-expect-error `selectionManager.state` is private\n listState.selectionManager.state.setSelectedKeys = (keys: Set<Key> | 'all') => {\n if (keys === 'all') {\n // When the end-user presses Ctrl/Cmd + A on a list which has `selectionMode` set to `'multiple'`,\n // the selection manager emits the `'all'` string as an indication to select all items.\n // We don't want to do that - instead, we select the contents of the input field.\n // Querying by ID because RACInputContext has a null ref for some reason.\n (document.getElementById(inputId) as HTMLInputElement | null)?.select();\n } else {\n setSelectedKeys(keys);\n }\n };\n // @ts-expect-error `selectionManager.state` is private\n listState.selectionManager.state.disallowEmptySelection = false;\n\n return {\n ...listState,\n };\n }, [listState, selectedKeys, setSelectedKeys, inputId]);\n\n const listBox = (\n <RACListBox className=\"cim-combo-box-listbox\" onScroll={onScroll} items={items}>\n {children}\n </RACListBox>\n );\n\n return (\n <RACListStateContext.Provider value={updatedListState}>\n {isVirtualized ? (\n <RACVirtualizer layout={RACListLayout} layoutOptions={VIRTUAL_LAYOUT_OPTIONS}>\n {listBox}\n </RACVirtualizer>\n ) : (\n listBox\n )}\n </RACListStateContext.Provider>\n );\n}\n"]}
@@ -24,7 +24,7 @@ export interface TagFieldProps<T extends CollectionItem = CollectionItem> extend
24
24
  /**
25
25
  * Allows users to filter a collapsible list and select multiple items from it.
26
26
  *
27
- * See [tag field usage guidelines](https://ui.cimpress.com/components/tag-field).
27
+ * See [tag field usage guidelines](https://ui.cimpress.io/components/tag-field).
28
28
  */
29
29
  declare const _TagField: <T extends CollectionItem>(props: TagFieldProps<T> & import("react").RefAttributes<HTMLDivElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
30
30
  export { _TagField as TagField };
@@ -125,7 +125,7 @@ function TagField({ label, description, error, items, children, placeholder, UNS
125
125
  /**
126
126
  * Allows users to filter a collapsible list and select multiple items from it.
127
127
  *
128
- * See [tag field usage guidelines](https://ui.cimpress.com/components/tag-field).
128
+ * See [tag field usage guidelines](https://ui.cimpress.io/components/tag-field).
129
129
  */
130
130
  const _TagField = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(TagField), 'TagField');
131
131
  exports.TagField = _TagField;
@@ -1 +1 @@
1
- {"version":3,"file":"tag-field.js","sourceRoot":"","sources":["../../../../src/components/tag-field/tag-field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAyVb,oCAqBC;AAYD,0CAoBC;;AA5YD,2CAAqD;AACrD,6CAAmE;AACnE,8CAA6D;AAC7D,gDAA0D;AAC1D,gDAAwB;AACxB,iCAAqE;AACrE,iEAiB+B;AAC/B,yDAAkD;AAClD,kFAA2E;AAC3E,mDAAsE;AACtE,mEAA4D;AAC5D,qFAA6E;AAC7E,mEAA2D;AAC3D,0FAAmF;AACnF,wEAA4G;AAU5G,qDAAmD;AACnD,6DAAqD;AACrD,mEAA0D;AAC1D,2DAAmD;AA2CnD,SAAS,QAAQ,CACf,EACE,KAAK,EACL,WAAW,EACX,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,UAAU,EAAE,kBAAkB,EAC9B,iBAAiB,EAAE,yBAAyB,EAC5C,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,YAAY,EAAE,oBAAoB,EAClC,mBAAmB,EAAE,2BAA2B,EAChD,iBAAiB,EACjB,EAAE,EACF,gBAAgB,EAChB,aAAa,GAAG,KAAK,EACrB,GAAG,KAAK,EACS,EACnB,GAAiC;IAEjC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAEhH,IAAA,gDAAoB,EAAC,GAAG,EAAE;QACxB,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,IAAI,CAAC,cAAc,EAAE,CAAC;YAC5C,OAAO,CAAC,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C;AAED,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAC","sourcesContent":["'use client';\n\nimport { useFormValidation } from '@react-aria/form';\nimport { useFormReset, useId, useSlotId } from '@react-aria/utils';\nimport { useFormValidationState } from '@react-stately/form';\nimport { useControlledState } from '@react-stately/utils';\nimport clsx from 'clsx';\nimport { useMemo, useRef, useState, type ForwardedRef } from 'react';\nimport {\n Button as RACButton,\n Collection as RACCollection,\n ComboBox as RACComboBox,\n Group as RACGroup,\n Header as RACHeader,\n Input as RACInput,\n type ListBoxProps as RACListBoxProps,\n ListBoxItem as RACListBoxItem,\n ListBoxSection as RACListBoxSection,\n Text as RACText,\n type ComboBoxProps as RACComboBoxProps,\n type ListBoxItemProps as RACListBoxItemProps,\n Provider as RACProvider,\n TextContext as RACTextContext,\n GroupContext as RACGroupContext,\n FieldErrorContext as RACFieldErrorContext,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/localization-provider.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 type { TagGroupProps } from '../tag/tag-group.js';\nimport type {\n CollectionItem,\n CollectionProps,\n CommonProps,\n FieldWithPlaceholderProps,\n Key,\n StringLikeChildren,\n} from '../types.js';\nimport { textStyle } from '../typography/utils.js';\nimport { TagFieldInput } from './tag-field-input.js';\nimport { TagFieldListBox } from './tag-field-list-box.js';\nimport { TagFieldTags } from './tag-field-tags.js';\n\n/** Represents the state of the `TagField` component for validation purposes. */\nexport interface TagFieldValidationValue {\n /** The selected keys in the TagField. */\n selectedKeys: Set<Key> | null;\n /** The value of the TagField input. */\n inputValue: string;\n}\n\nexport interface TagFieldProps<T extends CollectionItem = CollectionItem>\n extends CommonProps,\n FieldWithPlaceholderProps<TagFieldValidationValue>,\n CollectionProps<T>,\n Pick<\n RACComboBoxProps<T>,\n | 'isRequired'\n | 'isDisabled'\n | 'isInvalid'\n | 'isReadOnly'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onInputChange'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n >,\n Pick<RACListBoxProps<T>, 'onScroll'>,\n Pick<TagGroupProps<T>, 'renderEmptyState'> {\n /** The currently selected keys in the collection (controlled). */\n selectedKeys?: Iterable<Key>;\n /** The initial selected keys in the collection (uncontrolled). */\n defaultSelectedKeys?: Iterable<Key>;\n /** Handler that is called when the selection changes. */\n onSelectionChange?: (keys: Set<Key>) => 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}\n\nfunction TagField<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 inputValue: consumerInputValue,\n defaultInputValue: defaultConsumerInputValue,\n onInputChange,\n form,\n name,\n validate,\n onScroll,\n selectedKeys: consumerSelectedKeys,\n defaultSelectedKeys: defaultConsumerSelectedKeys,\n onSelectionChange,\n id,\n renderEmptyState,\n isVirtualized = false,\n ...props\n }: TagFieldProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, isRequired, isDisabled, isInvalid } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('TagField 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('`TagField` requires `children` to be a function when using `items` prop');\n }\n\n const messages = useLocalizedMessages('tagField');\n\n // State\n\n const [defaultSelectedKeys] = useState(() => defaultConsumerSelectedKeys ?? new Set<Key>());\n const [selectedKeys, setSelectedKeys] = useControlledState(\n consumerSelectedKeys,\n defaultSelectedKeys,\n onSelectionChange,\n );\n const [inputValue, setInputValue] = useControlledState(\n consumerInputValue,\n defaultConsumerInputValue ?? '',\n onInputChange,\n );\n\n const selectedSet = useMemo(() => {\n // eslint-disable-next-line unicorn/no-instanceof-builtins\n if (selectedKeys instanceof Set) {\n return new Set<Key>(selectedKeys.values());\n }\n\n return new Set<Key>(selectedKeys);\n }, [selectedKeys]);\n\n // Validation\n\n const inputId = useId(id);\n const formInputRef = useRef<HTMLInputElement>(null);\n\n const validationState = useFormValidationState({\n name,\n value: useMemo(() => ({ selectedKeys: selectedSet, inputValue }), [selectedSet, inputValue]),\n isInvalid,\n isRequired,\n validate,\n validationBehavior: 'native',\n });\n\n const [initialSelectedKeys] = useState(selectedKeys);\n const [initialInputValue] = useState(inputValue);\n\n useFormReset<[Iterable<Key>, string]>(\n formInputRef,\n [defaultConsumerSelectedKeys ?? initialSelectedKeys, defaultConsumerInputValue ?? initialInputValue],\n ([a, b]) => {\n setSelectedKeys(a);\n setInputValue(b);\n },\n );\n\n useFormValidation(\n {\n focus: () => {\n // Querying by element ID because a ref is always null here, I don't know why :(\n document.getElementById(inputId)?.focus();\n },\n isInvalid,\n isRequired,\n validate,\n validationBehavior: 'native',\n },\n validationState,\n formInputRef,\n );\n\n // Event handlers\n\n // Commit validation on input blur if the values have changed\n const inputValueOnFocus = useRef(inputValue);\n const selectedSetOnFocus = useRef(selectedSet);\n\n const onFocusChange = (isFocused: boolean) => {\n if (isFocused) {\n inputValueOnFocus.current = inputValue;\n selectedSetOnFocus.current = selectedSet;\n } else if (inputValue !== inputValueOnFocus.current || selectedSet !== selectedSetOnFocus.current) {\n validationState.commitValidation();\n }\n };\n\n const onItemSelectionChange = (key: Key) => {\n if (selectedSet.has(key)) {\n // This is a temporary mutation followed immediately by a state update, so this is fine\n // eslint-disable-next-line react-hooks/react-compiler\n selectedSet.delete(key);\n } else {\n selectedSet.add(key);\n }\n\n setSelectedKeys(new Set(selectedSet.values()));\n validationState.commitValidation();\n };\n\n // Text slots\n\n const descriptionId = useSlotId([Boolean(description)]);\n\n const errorMessageId = useSlotId([\n Boolean(error || validationState.displayValidation.validationErrors),\n validationState.displayValidation.isInvalid,\n ]);\n\n return (\n <>\n <RACComboBox\n {...props}\n ref={ref}\n id={inputId}\n className={clsx('cim-combo-box', 'cim-tag-field', UNSAFE_className)}\n style={UNSAFE_style}\n // Force no internal selection - we handle selection manually\n selectedKey={null}\n inputValue={inputValue}\n onInputChange={setInputValue}\n menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n onSelectionChange={(key) => {\n if (key) {\n onItemSelectionChange(key);\n }\n }}\n >\n <RACProvider\n values={[\n [RACTextContext, { slots: { description: { id: descriptionId }, errorMessage: { id: errorMessageId } } }],\n [RACGroupContext, { isInvalid: validationState.displayValidation.isInvalid, isDisabled }],\n [RACFieldErrorContext, validationState.displayValidation],\n ]}\n >\n <FormFieldLabel isRequired={isRequired} isDisabled={isDisabled}>\n {label}\n </FormFieldLabel>\n\n <RACGroup className=\"cim-combo-box-input-group\">\n <TagFieldInput\n aria-describedby={props['aria-describedby']}\n isReadOnly={isReadOnly}\n isRequired={isRequired}\n isInvalid={validationState.displayValidation.isInvalid}\n placeholder={\n selectedSet.size === 0 && placeholder\n ? placeholder\n : messages.format('itemsSelected', { selectedItemCount: selectedSet.size })\n }\n onFocusChange={onFocusChange}\n />\n <RACButton className=\"cim-combo-box-button\">\n <IconChevronDown />\n </RACButton>\n </RACGroup>\n\n <FormFieldError>{error}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n\n <TagFieldTags<T>\n inputId={inputId}\n selectedKeys={selectedSet}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n renderEmptyState={renderEmptyState}\n onRemove={onItemSelectionChange}\n />\n\n <CollapsibleList\n offset={5} // 1px border + 4px actual offset\n maxHeight={315}\n >\n <TagFieldListBox<T>\n inputId={inputId}\n items={items}\n selectedKeys={selectedSet}\n setSelectedKeys={setSelectedKeys}\n onScroll={onScroll}\n isVirtualized={isVirtualized}\n >\n {children}\n </TagFieldListBox>\n </CollapsibleList>\n </RACProvider>\n </RACComboBox>\n\n {/* This input is used for native form validation. We can't use the combo box input because its value has no relation to the selected values. */}\n <RACInput\n ref={formInputRef}\n style={{ display: 'none' }}\n value={selectedSet.size || ''}\n required={isRequired}\n aria-invalid={validationState.displayValidation.isInvalid || undefined}\n onChange={() => {}}\n />\n\n {/* These hidden inputs provide values when a form is submitted. */}\n {name &&\n [...selectedSet].map((value) => <input type=\"hidden\" key={value} form={form} name={name} value={value} />)}\n </>\n );\n}\n\n/**\n * Allows users to filter a collapsible list and select multiple items from it.\n *\n * See [tag field usage guidelines](https://ui.cimpress.com/components/tag-field).\n */\nconst _TagField = withStyleProps(forwardRef(TagField), 'TagField');\n\nexport { _TagField as TagField };\n\nexport interface TagFieldItemProps<T extends CollectionItem>\n extends Pick<RACListBoxItemProps<T>, 'id' | 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\n /** The content to display as the label. */\n children: StringLikeChildren;\n}\n\n/** Renders a single list item within `TagField`. */\nexport function TagFieldItem<T extends CollectionItem>({ children, ...props }: TagFieldItemProps<T>) {\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <RACListBoxItem {...props} className=\"cim-tag-field-item cim-checkbox\" textValue={textValue}>\n {({ isDisabled }) => (\n <>\n <div className=\"cim-checkbox-toggle-wrapper\" aria-hidden>\n <div className=\"cim-checkbox-toggle\">\n <IconCheckBold />\n </div>\n </div>\n\n <RACText slot=\"label\" className={textStyle({ variant: 'medium', tone: isDisabled ? 'muted' : 'base' })}>\n {children}\n </RACText>\n </>\n )}\n </RACListBoxItem>\n );\n}\n\nTagFieldItem.displayName = 'TagFieldItem';\n\nexport interface TagFieldSectionProps<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 `TagField` into a section. */\nexport function TagFieldSection<T extends CollectionItem>({\n title,\n children,\n items,\n ...props\n}: TagFieldSectionProps<T>) {\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`TagFieldSection` 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\nTagFieldSection.displayName = 'TagFieldSection';\n"]}
1
+ {"version":3,"file":"tag-field.js","sourceRoot":"","sources":["../../../../src/components/tag-field/tag-field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAyVb,oCAqBC;AAYD,0CAoBC;;AA5YD,2CAAqD;AACrD,6CAAmE;AACnE,8CAA6D;AAC7D,gDAA0D;AAC1D,gDAAwB;AACxB,iCAAqE;AACrE,iEAiB+B;AAC/B,yDAAkD;AAClD,kFAA2E;AAC3E,mDAAsE;AACtE,mEAA4D;AAC5D,qFAA6E;AAC7E,mEAA2D;AAC3D,0FAAmF;AACnF,wEAA4G;AAU5G,qDAAmD;AACnD,6DAAqD;AACrD,mEAA0D;AAC1D,2DAAmD;AA2CnD,SAAS,QAAQ,CACf,EACE,KAAK,EACL,WAAW,EACX,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,UAAU,EAAE,kBAAkB,EAC9B,iBAAiB,EAAE,yBAAyB,EAC5C,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,YAAY,EAAE,oBAAoB,EAClC,mBAAmB,EAAE,2BAA2B,EAChD,iBAAiB,EACjB,EAAE,EACF,gBAAgB,EAChB,aA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AAK,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 { useFormValidation } from '@react-aria/form';\nimport { useFormReset, useId, useSlotId } from '@react-aria/utils';\nimport { useFormValidationState } from '@react-stately/form';\nimport { useControlledState } from '@react-stately/utils';\nimport clsx from 'clsx';\nimport { useMemo, useRef, useState, type ForwardedRef } from 'react';\nimport {\n Button as RACButton,\n Collection as RACCollection,\n ComboBox as RACComboBox,\n Group as RACGroup,\n Header as RACHeader,\n Input as RACInput,\n type ListBoxProps as RACListBoxProps,\n ListBoxItem as RACListBoxItem,\n ListBoxSection as RACListBoxSection,\n Text as RACText,\n type ComboBoxProps as RACComboBoxProps,\n type ListBoxItemProps as RACListBoxItemProps,\n Provider as RACProvider,\n TextContext as RACTextContext,\n GroupContext as RACGroupContext,\n FieldErrorContext as RACFieldErrorContext,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/localization-provider.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 type { TagGroupProps } from '../tag/tag-group.js';\nimport type {\n CollectionItem,\n CollectionProps,\n CommonProps,\n FieldWithPlaceholderProps,\n Key,\n StringLikeChildren,\n} from '../types.js';\nimport { textStyle } from '../typography/utils.js';\nimport { TagFieldInput } from './tag-field-input.js';\nimport { TagFieldListBox } from './tag-field-list-box.js';\nimport { TagFieldTags } from './tag-field-tags.js';\n\n/** Represents the state of the `TagField` component for validation purposes. */\nexport interface TagFieldValidationValue {\n /** The selected keys in the TagField. */\n selectedKeys: Set<Key> | null;\n /** The value of the TagField input. */\n inputValue: string;\n}\n\nexport interface TagFieldProps<T extends CollectionItem = CollectionItem>\n extends CommonProps,\n FieldWithPlaceholderProps<TagFieldValidationValue>,\n CollectionProps<T>,\n Pick<\n RACComboBoxProps<T>,\n | 'isRequired'\n | 'isDisabled'\n | 'isInvalid'\n | 'isReadOnly'\n | 'inputValue'\n | 'defaultInputValue'\n | 'autoFocus'\n | 'onInputChange'\n | 'onFocus'\n | 'onBlur'\n | 'onOpenChange'\n >,\n Pick<RACListBoxProps<T>, 'onScroll'>,\n Pick<TagGroupProps<T>, 'renderEmptyState'> {\n /** The currently selected keys in the collection (controlled). */\n selectedKeys?: Iterable<Key>;\n /** The initial selected keys in the collection (uncontrolled). */\n defaultSelectedKeys?: Iterable<Key>;\n /** Handler that is called when the selection changes. */\n onSelectionChange?: (keys: Set<Key>) => 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}\n\nfunction TagField<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 inputValue: consumerInputValue,\n defaultInputValue: defaultConsumerInputValue,\n onInputChange,\n form,\n name,\n validate,\n onScroll,\n selectedKeys: consumerSelectedKeys,\n defaultSelectedKeys: defaultConsumerSelectedKeys,\n onSelectionChange,\n id,\n renderEmptyState,\n isVirtualized = false,\n ...props\n }: TagFieldProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, isRequired, isDisabled, isInvalid } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('TagField 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('`TagField` requires `children` to be a function when using `items` prop');\n }\n\n const messages = useLocalizedMessages('tagField');\n\n // State\n\n const [defaultSelectedKeys] = useState(() => defaultConsumerSelectedKeys ?? new Set<Key>());\n const [selectedKeys, setSelectedKeys] = useControlledState(\n consumerSelectedKeys,\n defaultSelectedKeys,\n onSelectionChange,\n );\n const [inputValue, setInputValue] = useControlledState(\n consumerInputValue,\n defaultConsumerInputValue ?? '',\n onInputChange,\n );\n\n const selectedSet = useMemo(() => {\n // eslint-disable-next-line unicorn/no-instanceof-builtins\n if (selectedKeys instanceof Set) {\n return new Set<Key>(selectedKeys.values());\n }\n\n return new Set<Key>(selectedKeys);\n }, [selectedKeys]);\n\n // Validation\n\n const inputId = useId(id);\n const formInputRef = useRef<HTMLInputElement>(null);\n\n const validationState = useFormValidationState({\n name,\n value: useMemo(() => ({ selectedKeys: selectedSet, inputValue }), [selectedSet, inputValue]),\n isInvalid,\n isRequired,\n validate,\n validationBehavior: 'native',\n });\n\n const [initialSelectedKeys] = useState(selectedKeys);\n const [initialInputValue] = useState(inputValue);\n\n useFormReset<[Iterable<Key>, string]>(\n formInputRef,\n [defaultConsumerSelectedKeys ?? initialSelectedKeys, defaultConsumerInputValue ?? initialInputValue],\n ([a, b]) => {\n setSelectedKeys(a);\n setInputValue(b);\n },\n );\n\n useFormValidation(\n {\n focus: () => {\n // Querying by element ID because a ref is always null here, I don't know why :(\n document.getElementById(inputId)?.focus();\n },\n isInvalid,\n isRequired,\n validate,\n validationBehavior: 'native',\n },\n validationState,\n formInputRef,\n );\n\n // Event handlers\n\n // Commit validation on input blur if the values have changed\n const inputValueOnFocus = useRef(inputValue);\n const selectedSetOnFocus = useRef(selectedSet);\n\n const onFocusChange = (isFocused: boolean) => {\n if (isFocused) {\n inputValueOnFocus.current = inputValue;\n selectedSetOnFocus.current = selectedSet;\n } else if (inputValue !== inputValueOnFocus.current || selectedSet !== selectedSetOnFocus.current) {\n validationState.commitValidation();\n }\n };\n\n const onItemSelectionChange = (key: Key) => {\n if (selectedSet.has(key)) {\n // This is a temporary mutation followed immediately by a state update, so this is fine\n // eslint-disable-next-line react-hooks/react-compiler\n selectedSet.delete(key);\n } else {\n selectedSet.add(key);\n }\n\n setSelectedKeys(new Set(selectedSet.values()));\n validationState.commitValidation();\n };\n\n // Text slots\n\n const descriptionId = useSlotId([Boolean(description)]);\n\n const errorMessageId = useSlotId([\n Boolean(error || validationState.displayValidation.validationErrors),\n validationState.displayValidation.isInvalid,\n ]);\n\n return (\n <>\n <RACComboBox\n {...props}\n ref={ref}\n id={inputId}\n className={clsx('cim-combo-box', 'cim-tag-field', UNSAFE_className)}\n style={UNSAFE_style}\n // Force no internal selection - we handle selection manually\n selectedKey={null}\n inputValue={inputValue}\n onInputChange={setInputValue}\n menuTrigger=\"focus\"\n isReadOnly={isReadOnly}\n data-readonly={isReadOnly ? true : undefined}\n onSelectionChange={(key) => {\n if (key) {\n onItemSelectionChange(key);\n }\n }}\n >\n <RACProvider\n values={[\n [RACTextContext, { slots: { description: { id: descriptionId }, errorMessage: { id: errorMessageId } } }],\n [RACGroupContext, { isInvalid: validationState.displayValidation.isInvalid, isDisabled }],\n [RACFieldErrorContext, validationState.displayValidation],\n ]}\n >\n <FormFieldLabel isRequired={isRequired} isDisabled={isDisabled}>\n {label}\n </FormFieldLabel>\n\n <RACGroup className=\"cim-combo-box-input-group\">\n <TagFieldInput\n aria-describedby={props['aria-describedby']}\n isReadOnly={isReadOnly}\n isRequired={isRequired}\n isInvalid={validationState.displayValidation.isInvalid}\n placeholder={\n selectedSet.size === 0 && placeholder\n ? placeholder\n : messages.format('itemsSelected', { selectedItemCount: selectedSet.size })\n }\n onFocusChange={onFocusChange}\n />\n <RACButton className=\"cim-combo-box-button\">\n <IconChevronDown />\n </RACButton>\n </RACGroup>\n\n <FormFieldError>{error}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n\n <TagFieldTags<T>\n inputId={inputId}\n selectedKeys={selectedSet}\n isDisabled={isDisabled}\n isReadOnly={isReadOnly}\n renderEmptyState={renderEmptyState}\n onRemove={onItemSelectionChange}\n />\n\n <CollapsibleList\n offset={5} // 1px border + 4px actual offset\n maxHeight={315}\n >\n <TagFieldListBox<T>\n inputId={inputId}\n items={items}\n selectedKeys={selectedSet}\n setSelectedKeys={setSelectedKeys}\n onScroll={onScroll}\n isVirtualized={isVirtualized}\n >\n {children}\n </TagFieldListBox>\n </CollapsibleList>\n </RACProvider>\n </RACComboBox>\n\n {/* This input is used for native form validation. We can't use the combo box input because its value has no relation to the selected values. */}\n <RACInput\n ref={formInputRef}\n style={{ display: 'none' }}\n value={selectedSet.size || ''}\n required={isRequired}\n aria-invalid={validationState.displayValidation.isInvalid || undefined}\n onChange={() => {}}\n />\n\n {/* These hidden inputs provide values when a form is submitted. */}\n {name &&\n [...selectedSet].map((value) => <input type=\"hidden\" key={value} form={form} name={name} value={value} />)}\n </>\n );\n}\n\n/**\n * Allows users to filter a collapsible list and select multiple items from it.\n *\n * See [tag field usage guidelines](https://ui.cimpress.io/components/tag-field).\n */\nconst _TagField = withStyleProps(forwardRef(TagField), 'TagField');\n\nexport { _TagField as TagField };\n\nexport interface TagFieldItemProps<T extends CollectionItem>\n extends Pick<RACListBoxItemProps<T>, 'id' | 'isDisabled' | 'onHoverStart' | 'onHoverEnd'> {\n /** The content to display as the label. */\n children: StringLikeChildren;\n}\n\n/** Renders a single list item within `TagField`. */\nexport function TagFieldItem<T extends CollectionItem>({ children, ...props }: TagFieldItemProps<T>) {\n const textValue =\n typeof children === 'string' ? children : typeof children === 'number' ? String(children) : children.join('');\n\n return (\n <RACListBoxItem {...props} className=\"cim-tag-field-item cim-checkbox\" textValue={textValue}>\n {({ isDisabled }) => (\n <>\n <div className=\"cim-checkbox-toggle-wrapper\" aria-hidden>\n <div className=\"cim-checkbox-toggle\">\n <IconCheckBold />\n </div>\n </div>\n\n <RACText slot=\"label\" className={textStyle({ variant: 'medium', tone: isDisabled ? 'muted' : 'base' })}>\n {children}\n </RACText>\n </>\n )}\n </RACListBoxItem>\n );\n}\n\nTagFieldItem.displayName = 'TagFieldItem';\n\nexport interface TagFieldSectionProps<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 `TagField` into a section. */\nexport function TagFieldSection<T extends CollectionItem>({\n title,\n children,\n items,\n ...props\n}: TagFieldSectionProps<T>) {\n if (!isProduction() && items != null && typeof children !== 'function') {\n console.warn('`TagFieldSection` 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\nTagFieldSection.displayName = 'TagFieldSection';\n"]}
@@ -0,0 +1,12 @@
1
+ import { type SearchFieldProps as RACSearchFieldProps } from 'react-aria-components';
2
+ import type { CommonProps, FieldWithPlaceholderProps } from '../types.js';
3
+ export interface SearchFieldProps extends CommonProps, FieldWithPlaceholderProps<string>, Pick<RACSearchFieldProps, 'value' | 'defaultValue' | 'onChange' | 'onSubmit' | 'onClear' | 'isDisabled' | 'isRequired' | 'isInvalid' | 'isReadOnly' | 'autoFocus' | 'autoComplete' | 'autoCorrect' | 'spellCheck' | 'inputMode' | 'minLength' | 'maxLength' | 'pattern' | 'onFocus' | 'onBlur'> {
4
+ }
5
+ /**
6
+ * Allows users to enter and clear a search query.
7
+ *
8
+ * See [search field usage guidelines](https://ui.cimpress.io/components/search-field/).
9
+ */
10
+ declare const _SearchField: (props: SearchFieldProps & import("react").RefAttributes<HTMLDivElement> & import("../../with-style-props.js").StyleProps) => import("react").JSX.Element | null;
11
+ export { _SearchField as SearchField };
12
+ //# sourceMappingURL=search-field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-field.d.ts","sourceRoot":"","sources":["../../../../src/components/text-inputs/search-field.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,gBAAgB,IAAI,mBAAmB,EAE7C,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,KAAK,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAG1E,MAAM,WAAW,gBACf,SAAQ,WAAW,EACjB,yBAAyB,CAAC,MAAM,CAAC,EACjC,IAAI,CACF,mBAAmB,EACjB,OAAO,GACP,cAAc,GACd,UAAU,GACV,UAAU,GACV,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,WAAW,GACX,cAAc,GACd,aAAa,GACb,YAAY,GACZ,WAAW,GACX,WAAW,GACX,WAAW,GACX,SAAS,GACT,SAAS,GACT,QAAQ,CACX;CAAG;AAkER;;;;GAIG;AACH,QAAA,MAAM,YAAY,kKAAyD,CAAC;AAE5E,OAAO,EAAE,YAAY,IAAI,WAAW,EAAE,CAAC"}
@@ -0,0 +1,38 @@
1
+ 'use client';
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.SearchField = void 0;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const clsx_1 = __importDefault(require("clsx"));
10
+ const react_1 = require("react");
11
+ const react_aria_components_1 = require("react-aria-components");
12
+ const forward_ref_js_1 = require("../../forward-ref.js");
13
+ const localization_provider_js_1 = require("../../i18n/localization-provider.js");
14
+ const index_js_1 = require("../../icons/index.js");
15
+ const use_production_warning_js_1 = require("../../utils/use-production-warning.js");
16
+ const with_style_props_js_1 = require("../../with-style-props.js");
17
+ const form_field_js_1 = require("../internal/form-field/form-field.js");
18
+ const x_button_js_1 = require("../internal/x-button/x-button.js");
19
+ const utils_js_1 = require("../typography/utils.js");
20
+ function SearchField({ label, description, error: errorMessage, placeholder, UNSAFE_className, UNSAFE_style, ...props }, ref) {
21
+ const inputRef = (0, react_1.useRef)(null);
22
+ const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;
23
+ (0, use_production_warning_js_1.useProductionWarning)(() => {
24
+ if (!label && !ariaLabel && !ariaLabelledBy) {
25
+ console.warn('SearchField requires one of label / aria-label / aria-labelledby for accessibility');
26
+ }
27
+ }, [label, ariaLabel, ariaLabelledBy]);
28
+ const commonMessages = (0, localization_provider_js_1.useLocalizedMessages)('common');
29
+ return ((0, jsx_runtime_1.jsx)(react_aria_components_1.SearchField, { ...props, ref: ref, className: (0, clsx_1.default)('cim-search-field', UNSAFE_className), style: UNSAFE_style, enterKeyHint: "search", children: ({ state }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { 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-search-field-input-group", onClick: () => inputRef.current?.focus(), children: [(0, jsx_runtime_1.jsx)("div", { className: (0, clsx_1.default)('cim-text-field-affix', (0, utils_js_1.textStyle)({ variant: 'body', tone: props.isDisabled ? 'muted' : 'subtle' })), "aria-hidden": true, children: (0, jsx_runtime_1.jsx)(index_js_1.IconSearch, {}) }), (0, jsx_runtime_1.jsx)(react_aria_components_1.Input, { ref: inputRef, className: (0, clsx_1.default)('cim-search-field-input', (0, utils_js_1.textStyle)({ variant: 'body' })), placeholder: placeholder }), state.value !== '' && !props.isDisabled && !props.isReadOnly && ((0, jsx_runtime_1.jsx)(x_button_js_1.XButton, { UNSAFE_className: "cim-search-field-clear", "aria-label": commonMessages.format('clearValue'), iconType: "circled" }))] }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: errorMessage }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description })] })) }));
30
+ }
31
+ /**
32
+ * Allows users to enter and clear a search query.
33
+ *
34
+ * See [search field usage guidelines](https://ui.cimpress.io/components/search-field/).
35
+ */
36
+ const _SearchField = (0, with_style_props_js_1.withStyleProps)((0, forward_ref_js_1.forwardRef)(SearchField), 'SearchField');
37
+ exports.SearchField = _SearchField;
38
+ //# sourceMappingURL=search-field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-field.js","sourceRoot":"","sources":["../../../../src/components/text-inputs/search-field.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AACxB,iCAAkD;AAClD,iEAK+B;AAC/B,yDAAkD;AAClD,kFAA2E;AAC3E,mDAAkD;AAClD,qFAA6E;AAC7E,mEAA2D;AAC3D,wEAA4G;AAC5G,kEAA2D;AAE3D,qDAAmD;AA4BnD,SAAS,WAAW,CAClB,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,GAAG,KAAK,EAAoB,EACpH,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,oFAAoF,CAAC,CAAC;QACrG,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IAEvC,MAAM,cA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AAoB,cAAE,WAAW,GAAwB,IACzD,CACJ,GACc,CAClB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,YAAY,GAAG,IAAA,oCAAc,EAAC,IAAA,2BAAU,EAAC,WAAW,CAAC,EAAE,aAAa,CAAC,CAAC;AAEnD,mCAAW","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { useRef, type ForwardedRef } from 'react';\nimport {\n Input as RACInput,\n SearchField as RACSearchField,\n type SearchFieldProps as RACSearchFieldProps,\n Group as RACGroup,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useLocalizedMessages } from '../../i18n/localization-provider.js';\nimport { IconSearch } from '../../icons/index.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport { XButton } from '../internal/x-button/x-button.js';\nimport type { CommonProps, FieldWithPlaceholderProps } from '../types.js';\nimport { textStyle } from '../typography/utils.js';\n\nexport interface SearchFieldProps\n extends CommonProps,\n FieldWithPlaceholderProps<string>,\n Pick<\n RACSearchFieldProps,\n | 'value'\n | 'defaultValue'\n | 'onChange'\n | 'onSubmit'\n | 'onClear'\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'autoFocus'\n | 'autoComplete'\n | 'autoCorrect'\n | 'spellCheck'\n | 'inputMode'\n | 'minLength'\n | 'maxLength'\n | 'pattern'\n | 'onFocus'\n | 'onBlur'\n > {}\n\nfunction SearchField(\n { label, description, error: errorMessage, placeholder, UNSAFE_className, UNSAFE_style, ...props }: SearchFieldProps,\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('SearchField requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n const commonMessages = useLocalizedMessages('common');\n\n return (\n <RACSearchField\n {...props}\n ref={ref}\n className={clsx('cim-search-field', UNSAFE_className)}\n style={UNSAFE_style}\n enterKeyHint=\"search\"\n >\n {({ state }) => (\n <>\n <FormFieldLabel isRequired={props.isRequired} isDisabled={props.isDisabled}>\n {label}\n </FormFieldLabel>\n\n <RACGroup className=\"cim-search-field-input-group\" onClick={() => inputRef.current?.focus()}>\n <div\n className={clsx(\n 'cim-text-field-affix',\n textStyle({ variant: 'body', tone: props.isDisabled ? 'muted' : 'subtle' }),\n )}\n aria-hidden\n >\n <IconSearch />\n </div>\n\n <RACInput\n ref={inputRef}\n className={clsx('cim-search-field-input', textStyle({ variant: 'body' }))}\n placeholder={placeholder}\n />\n\n {state.value !== '' && !props.isDisabled && !props.isReadOnly && (\n <XButton\n UNSAFE_className=\"cim-search-field-clear\"\n aria-label={commonMessages.format('clearValue')}\n iconType=\"circled\"\n />\n )}\n </RACGroup>\n\n <FormFieldError>{errorMessage}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n </>\n )}\n </RACSearchField>\n );\n}\n\n/**\n * Allows users to enter and clear a search query.\n *\n * See [search field usage guidelines](https://ui.cimpress.io/components/search-field/).\n */\nconst _SearchField = withStyleProps(forwardRef(SearchField), 'SearchField');\n\nexport { _SearchField as SearchField };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"text-area.d.ts","sourceRoot":"","sources":["../../../../src/components/text-inputs/text-area.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,aAAa,IAAI,gBAAgB,EACtC,KAAK,cAAc,IAAI,iBAAiB,EAEzC,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAG1E,MAAM,WAAW,aACf,SAAQ,WAAW,EACjB,yBAAyB,CAAC,MAAM,CAAC,EACjC,IAAI,CACF,iBAAiB,EACf,OAAO,GACP,cAAc,GACd,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,MAAM,GACN,WAAW,GACX,cAAc,GACd,WAAW,GACX,WAAW,GACX,WAAW,GACX,SAAS,GACT,QAAQ,CACX,EACD,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,aAAa,GAAG,MAAM,GAAG,YAAY,GAAG,MAAM,CAAC;CAAG;AAsDhG;;;;GAIG;AACH,QAAA,MAAM,SAAS,+JAAmD,CAAC;AAEnE,OAAO,EAAE,SAAS,IAAI,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"text-area.d.ts","sourceRoot":"","sources":["../../../../src/components/text-inputs/text-area.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,aAAa,IAAI,gBAAgB,EACtC,KAAK,cAAc,IAAI,iBAAiB,EAEzC,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAG1E,MAAM,WAAW,aACf,SAAQ,WAAW,EACjB,yBAAyB,CAAC,MAAM,CAAC,EACjC,IAAI,CACF,iBAAiB,EACf,OAAO,GACP,cAAc,GACd,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,MAAM,GACN,WAAW,GACX,cAAc,GACd,WAAW,GACX,WAAW,GACX,WAAW,GACX,SAAS,GACT,QAAQ,CACX,EACD,IAAI,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,aAAa,GAAG,MAAM,GAAG,YAAY,GAAG,MAAM,CAAC;CAAG;AAwDhG;;;;GAIG;AACH,QAAA,MAAM,SAAS,+JAAmD,CAAC;AAEnE,OAAO,EAAE,SAAS,IAAI,QAAQ,EAAE,CAAC"}
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.TextArea = void 0;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
9
  const clsx_1 = __importDefault(require("clsx"));
10
+ const react_1 = require("react");
10
11
  const react_aria_components_1 = require("react-aria-components");
11
12
  const forward_ref_js_1 = require("../../forward-ref.js");
12
13
  const use_production_warning_js_1 = require("../../utils/use-production-warning.js");
@@ -14,13 +15,14 @@ const with_style_props_js_1 = require("../../with-style-props.js");
14
15
  const form_field_js_1 = require("../internal/form-field/form-field.js");
15
16
  const utils_js_1 = require("../typography/utils.js");
16
17
  function TextArea({ label, description, error: errorMessage, placeholder, autoCapitalize, autoCorrect, rows, spellCheck, wrap, UNSAFE_className, UNSAFE_style, ...props }, ref) {
18
+ const textAreaRef = (0, react_1.useRef)(null);
17
19
  const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;
18
20
  (0, use_production_warning_js_1.useProductionWarning)(() => {
19
21
  if (!label && !ariaLabel && !ariaLabelledBy) {
20
22
  console.warn('TextArea requires one of label / aria-label / aria-labelledby for accessibility');
21
23
  }
22
24
  }, [label, ariaLabel, ariaLabelledBy]);
23
- return ((0, jsx_runtime_1.jsx)(react_aria_components_1.TextField, { ...props, ref: ref, className: (0, clsx_1.default)('cim-text-area', UNSAFE_className), style: UNSAFE_style, children: ({ isDisabled, isInvalid, isRequired }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: isRequired, isDisabled: isDisabled, children: label }), (0, jsx_runtime_1.jsx)(react_aria_components_1.Group, { className: "cim-text-area-input-group", isDisabled: isDisabled, isInvalid: isInvalid, children: (0, jsx_runtime_1.jsx)(react_aria_components_1.TextArea, { className: (0, clsx_1.default)('cim-text-area-input', (0, utils_js_1.textStyle)({ variant: 'body' })), placeholder: placeholder, autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, rows: rows, spellCheck: spellCheck, wrap: wrap }) }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: errorMessage }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description })] })) }));
25
+ return ((0, jsx_runtime_1.jsx)(react_aria_components_1.TextField, { ...props, ref: ref, className: (0, clsx_1.default)('cim-text-area', UNSAFE_className), style: UNSAFE_style, children: ({ isDisabled, isRequired }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldLabel, { isRequired: isRequired, isDisabled: isDisabled, children: label }), (0, jsx_runtime_1.jsx)(react_aria_components_1.Group, { className: "cim-text-area-input-group", onClick: () => textAreaRef.current?.focus(), children: (0, jsx_runtime_1.jsx)(react_aria_components_1.TextArea, { ref: textAreaRef, className: (0, clsx_1.default)('cim-text-area-input', (0, utils_js_1.textStyle)({ variant: 'body' })), placeholder: placeholder, autoCapitalize: autoCapitalize, autoCorrect: autoCorrect, rows: rows, spellCheck: spellCheck, wrap: wrap }) }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldError, { children: errorMessage }), (0, jsx_runtime_1.jsx)(form_field_js_1.FormFieldDescription, { children: description })] })) }));
24
26
  }
25
27
  /**
26
28
  * Allows users to enter multiple lines of text with a keyboard.
@@ -1 +1 @@
1
- {"version":3,"file":"text-area.js","sourceRoot":"","sources":["../../../../src/components/text-inputs/text-area.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AAExB,iEAM+B;AAC/B,yDAAkD;AAClD,qFAA6E;AAC7E,mEAA2D;AAC3D,wEAA4G;AAE5G,qDAAmD;AAyBnD,SAAS,QAAQ,CACf,EACE,KAAK,EACL,WAAW,EACX,KAAK,EAAE,YAAY,EACnB,WAAW,EACX,cAAc,EACd,WAAW,EACX,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,GAAG,KAAK,EACM,EAChB,GAAiC;IAEjC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,cAAc,EAAE,GAAG,K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import clsx from 'clsx';\nimport type { ForwardedRef } from 'react';\nimport {\n TextArea as RACTextArea,\n TextField as RACTextField,\n type TextAreaProps as RACTextAreaProps,\n type TextFieldProps as RACTextFieldProps,\n Group as RACGroup,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport type { CommonProps, FieldWithPlaceholderProps } from '../types.js';\nimport { textStyle } from '../typography/utils.js';\n\nexport interface TextAreaProps\n extends CommonProps,\n FieldWithPlaceholderProps<string>,\n Pick<\n RACTextFieldProps,\n | 'value'\n | 'defaultValue'\n | 'onChange'\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'type'\n | 'autoFocus'\n | 'autoComplete'\n | 'inputMode'\n | 'minLength'\n | 'maxLength'\n | 'onFocus'\n | 'onBlur'\n >,\n Pick<RACTextAreaProps, 'autoCapitalize' | 'autoCorrect' | 'rows' | 'spellCheck' | 'wrap'> {}\n\nfunction TextArea(\n {\n label,\n description,\n error: errorMessage,\n placeholder,\n autoCapitalize,\n autoCorrect,\n rows,\n spellCheck,\n wrap,\n UNSAFE_className,\n UNSAFE_style,\n ...props\n }: TextAreaProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('TextArea requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n return (\n <RACTextField {...props} ref={ref} className={clsx('cim-text-area', UNSAFE_className)} style={UNSAFE_style}>\n {/* RAC doesn't pass `isDisabled` or `isInvalid` to `Group` through context as it does with `NumberField`, so we need to pass them manually */}\n {({ isDisabled, isInvalid, isRequired }) => (\n <>\n <FormFieldLabel isRequired={isRequired} isDisabled={isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-text-area-input-group\" isDisabled={isDisabled} isInvalid={isInvalid}>\n <RACTextArea\n className={clsx('cim-text-area-input', textStyle({ variant: 'body' }))}\n placeholder={placeholder}\n autoCapitalize={autoCapitalize}\n autoCorrect={autoCorrect}\n rows={rows}\n spellCheck={spellCheck}\n wrap={wrap}\n />\n </RACGroup>\n <FormFieldError>{errorMessage}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n </>\n )}\n </RACTextField>\n );\n}\n\n/**\n * Allows users to enter multiple lines of text with a keyboard.\n *\n * See [text area usage guidelines](https://ui.cimpress.io/components/text-area/).\n */\nconst _TextArea = withStyleProps(forwardRef(TextArea), 'TextArea');\n\nexport { _TextArea as TextArea };\n"]}
1
+ {"version":3,"file":"text-area.js","sourceRoot":"","sources":["../../../../src/components/text-inputs/text-area.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;AAEb,gDAAwB;AACxB,iCAAkD;AAClD,iEAM+B;AAC/B,yDAAkD;AAClD,qFAA6E;AAC7E,mEAA2D;AAC3D,wEAA4G;AAE5G,qDAAmD;AAyBnD,SAAS,QAAQ,CACf,EACE,KAAK,EACL,WAAW,EACX,KAAK,EAAE,YAAY,EACnB,WAAW,EACX,cAAc,EACd,WAAW,EACX,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,GAAG,KAAK,EACM,EAChB,GAAiC;IAEjC,MAAM,WAAW,GAAG,IAAA,cAAM,EAAsB,IAAI,CAAC,CAAC;IAEtD,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,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IAEvC,OAAO,CACL,uBAAC,iCAAY,OAAK,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAA,cAAI,EAAC,eAAe,EAAE,gBAAgB,CAAC,EAAE,KAAK,EAAE,YAAY,YACvG,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAC/B,6DACE,uBAAC,8BAAc,IAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,YAC3D,KAAK,GACS,EACjB,uBAAC,6BAAQ,IAAC,SAAS,EAAC,2BAA2B,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,EAAE,YACzF,uBAAC,gCAAW,IACV,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,IAAA,cAAI,EAAC,qBAAqB,EAAE,IAAA,oBAAS,EAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,EACtE,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,GACV,GACO,EACX,uBAAC,8BAAc,cAAE,YAAY,GAAkB,EAC/C,uBAAC,oCAAoB,cAAE,WAAW,GAAwB,IACzD,CACJ,GACY,CAChB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,SAAS,GAAG,IAAA,oCAAc,EAAC,IAAA,2BAAU,EAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC;AAE7C,6BAAQ","sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { useRef, type ForwardedRef } from 'react';\nimport {\n TextArea as RACTextArea,\n TextField as RACTextField,\n type TextAreaProps as RACTextAreaProps,\n type TextFieldProps as RACTextFieldProps,\n Group as RACGroup,\n} from 'react-aria-components';\nimport { forwardRef } from '../../forward-ref.js';\nimport { useProductionWarning } from '../../utils/use-production-warning.js';\nimport { withStyleProps } from '../../with-style-props.js';\nimport { FormFieldDescription, FormFieldError, FormFieldLabel } from '../internal/form-field/form-field.js';\nimport type { CommonProps, FieldWithPlaceholderProps } from '../types.js';\nimport { textStyle } from '../typography/utils.js';\n\nexport interface TextAreaProps\n extends CommonProps,\n FieldWithPlaceholderProps<string>,\n Pick<\n RACTextFieldProps,\n | 'value'\n | 'defaultValue'\n | 'onChange'\n | 'isDisabled'\n | 'isRequired'\n | 'isInvalid'\n | 'isReadOnly'\n | 'type'\n | 'autoFocus'\n | 'autoComplete'\n | 'inputMode'\n | 'minLength'\n | 'maxLength'\n | 'onFocus'\n | 'onBlur'\n >,\n Pick<RACTextAreaProps, 'autoCapitalize' | 'autoCorrect' | 'rows' | 'spellCheck' | 'wrap'> {}\n\nfunction TextArea(\n {\n label,\n description,\n error: errorMessage,\n placeholder,\n autoCapitalize,\n autoCorrect,\n rows,\n spellCheck,\n wrap,\n UNSAFE_className,\n UNSAFE_style,\n ...props\n }: TextAreaProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n\n const { 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy } = props;\n\n useProductionWarning(() => {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn('TextArea requires one of label / aria-label / aria-labelledby for accessibility');\n }\n }, [label, ariaLabel, ariaLabelledBy]);\n\n return (\n <RACTextField {...props} ref={ref} className={clsx('cim-text-area', UNSAFE_className)} style={UNSAFE_style}>\n {({ isDisabled, isRequired }) => (\n <>\n <FormFieldLabel isRequired={isRequired} isDisabled={isDisabled}>\n {label}\n </FormFieldLabel>\n <RACGroup className=\"cim-text-area-input-group\" onClick={() => textAreaRef.current?.focus()}>\n <RACTextArea\n ref={textAreaRef}\n className={clsx('cim-text-area-input', textStyle({ variant: 'body' }))}\n placeholder={placeholder}\n autoCapitalize={autoCapitalize}\n autoCorrect={autoCorrect}\n rows={rows}\n spellCheck={spellCheck}\n wrap={wrap}\n />\n </RACGroup>\n <FormFieldError>{errorMessage}</FormFieldError>\n <FormFieldDescription>{description}</FormFieldDescription>\n </>\n )}\n </RACTextField>\n );\n}\n\n/**\n * Allows users to enter multiple lines of text with a keyboard.\n *\n * See [text area usage guidelines](https://ui.cimpress.io/components/text-area/).\n */\nconst _TextArea = withStyleProps(forwardRef(TextArea), 'TextArea');\n\nexport { _TextArea as TextArea };\n"]}
@@ -1,6 +1,6 @@
1
1
  import { type TextFieldProps as RACTextFieldProps } from 'react-aria-components';
2
- import type { CommonProps, FieldWithPlaceholderProps } from '../types.js';
3
- export interface TextFieldProps extends CommonProps, FieldWithPlaceholderProps<string>, Pick<RACTextFieldProps, 'value' | 'defaultValue' | 'onChange' | 'isDisabled' | 'isRequired' | 'isInvalid' | 'isReadOnly' | 'type' | 'autoFocus' | 'autoComplete' | 'inputMode' | 'minLength' | 'maxLength' | 'pattern' | 'onFocus' | 'onBlur'> {
2
+ import type { AffixProps, CommonProps, FieldWithPlaceholderProps } from '../types.js';
3
+ export interface TextFieldProps extends CommonProps, FieldWithPlaceholderProps<string>, AffixProps, Pick<RACTextFieldProps, 'value' | 'defaultValue' | 'onChange' | 'isDisabled' | 'isRequired' | 'isInvalid' | 'isReadOnly' | 'type' | 'autoFocus' | 'autoComplete' | 'inputMode' | 'minLength' | 'maxLength' | 'pattern' | 'onFocus' | 'onBlur'> {
4
4
  }
5
5
  /**
6
6
  * Allows users to enter a single line of text with a keyboard.
@@ -1 +1 @@
1
- {"version":3,"file":"text-field.d.ts","sourceRoot":"","sources":["../../../../src/components/text-inputs/text-field.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,cAAc,IAAI,iBAAiB,EAEzC,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAG1E,MAAM,WAAW,cACf,SAAQ,WAAW,EACjB,yBAAyB,CAAC,MAAM,CAAC,EACjC,IAAI,CACF,iBAAiB,EACf,OAAO,GACP,cAAc,GACd,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,MAAM,GACN,WAAW,GACX,cAAc,GACd,WAAW,GACX,WAAW,GACX,WAAW,GACX,SAAS,GACT,SAAS,GACT,QAAQ,CACX;CAAG;AAmCR;;;;GAIG;AACH,QAAA,MAAM,UAAU,gKAAqD,CAAC;AAEtE,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"text-field.d.ts","sourceRoot":"","sources":["../../../../src/components/text-inputs/text-field.tsx"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,cAAc,IAAI,iBAAiB,EAEzC,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAGtF,MAAM,WAAW,cACf,SAAQ,WAAW,EACjB,yBAAyB,CAAC,MAAM,CAAC,EACjC,UAAU,EACV,IAAI,CACF,iBAAiB,EACf,OAAO,GACP,cAAc,GACd,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,MAAM,GACN,WAAW,GACX,cAAc,GACd,WAAW,GACX,WAAW,GACX,WAAW,GACX,SAAS,GACT,SAAS,GACT,QAAQ,CACX;CAAG;AAmFR;;;;GAIG;AACH,QAAA,MAAM,UAAU,gKAAqD,CAAC;AAEtE,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,CAAC"}